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

regarding The regular expression

Former Member
0 Likes
1,808

Hi all:

there is an error in the following statement , the error messge while activating the system says

The regular expression '|' is invalid character at position 1., could u pls tell me how exactly correct the following statements.

REPLACE ALL OCCURRENCES of REGEX '|' in s_name1 with ''.

REPLACE ALL OCCURRENCES of REGEX '?' in s_name1 with ''.

REPLACE ALL OCCURRENCES of REGEX '*' in s_name1 with ''.

Thank u vrey much for any reply

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,194

Hi,

Please look for F1 on REGEX. The character which needs to be replaced should be at position 1.

DATA : text TYPE string VALUE 'aa-'.

REPLACE ALL OCCURRENCES OF REGEX 'a*' IN text WITH 'y'.

Regards,

Srini.

4 REPLIES 4
Read only

Former Member
0 Likes
1,195

Hi,

Please look for F1 on REGEX. The character which needs to be replaced should be at position 1.

DATA : text TYPE string VALUE 'aa-'.

REPLACE ALL OCCURRENCES OF REGEX 'a*' IN text WITH 'y'.

Regards,

Srini.

Read only

0 Likes
1,194

|, * and ? are all 'special' characters in regular expressions. I believe you want to replace exactly those literals in your text and not to use them as meta-characters. If this is so, then just try to escape them. Probably prefixing your chars with backslash will help: \| \* \?. If not, read the docs for escaping.

Read only

ThomasZloch
Active Contributor
0 Likes
1,194

You probably don't need the REGEX option at all for that simple replace that you are trying to do. Read the F1 help for REPLACE carefully.

Thomas

Read only

0 Likes
1,194

hi ,

I agree with thomas , u dont have to specify REGEX ...

For Ex :

data : g_str2(100) type c value '12:30:40'.

REPLACE ALL OCCURRENCES OF ':' IN G_STR2 WITH SPACE.

Result : g_str2 = 12 30 40.

All occurances of g_str2 will be replaced by space.

Cheers !

Soumya Ranjan