Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

string contains special chars

Former Member
0 Likes
1,296

Hi there,

If given string contains a special character in the first position..i need to delete the character from the string.

please suggest a way..

Hi there,

If given string contains a special character in the first position..i need to delete the character from the string.

please suggest a way..

10 REPLIES 10
Read only

Former Member
0 Likes
1,240

Hi Tuborg,

Use offset to delete it.

Refer this seudo code :

data : d_string type string value '@abcdef'.

d_string = d_string+1(6).

Regards,

Hemant

Read only

former_member188827
Active Contributor
0 Likes
1,240

if str+0(1) eq 'your_special_character>'.

str+0(1) eq ' '.

shift str left deleting leading space.

endif.

Read only

Former Member
0 Likes
1,240

creaate a range containing all the alphabets.. both small n capital...

data: str1(10).

if str1+0(1) NOT IN range.

SHIFT str1 BY 1 PLACES LEFT.

endif.

Read only

Former Member
0 Likes
1,240

hi

good

use strlen and get the length of the string than delete the first letter as per the position starting from 0,

thanks

mrutyun^

Read only

Former Member
0 Likes
1,240

It's clunky, but try this:

  • To replace special character with space.

data: w_val type string.

move old_string+0(1) to w_val.

replace first occurance of w_val in old_string with space.

OR

  • To remove it entirely

shift old_string by 1 places left. " Shifts string to left and drops off characters to left.

Steve

Read only

0 Likes
1,240

thanks.

but not always the first char will be the special char..How to check the first char is the special char?

Read only

Former Member
0 Likes
1,240

any ideas??

Read only

0 Likes
1,240

by creating a range of the aplhabets .. you are defining all the non-special characters...

as you cant possibly list down all the characters...

so in the condition check if string+0(1) i.e. 1st char of string is ther in the range or not..

if not in the range... that is your special character... remove it

Read only

0 Likes
1,240

if str+0(1) eq 'your_special_character>'.

str+0(1) eq ' '.

shift str left deleting leading space.

endif.

str+0(1) checks only da first character. if it is special character it 'll delete it else da string 'll remain same.

try da code n den leme kno if its working or not

Read only

Former Member
0 Likes
1,240

Hi,

If you knw the Ascii codes, then its pretty simple:

if string+0(1) GE 65 and string+0(1) LE 91.
...
endif.

Best regards,

Prashant