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

Replace substring within Brackets with regex

casualCoder
Participant
0 Likes
2,060

Hi,

the following String is given: '{12ZT-}716Ghdnsba'.

I want to cut the text within the Brackets, so the result would be '716Ghdnsba'.

Can anybody show me the approach with Regular Expressions? (regex?)

PCRE or POSIX?

or just use substring_after( ... sub = '}' ), no?

4 REPLIES 4
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,907

You can replace a regex pattern in a string using a syntax such as

REPLACE PCRE <regex pattern> IN <string> WITH ``.

For example try with a pattern such as \{.*\} (try demo report DEMO_REGEX)

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,907

PCRE or POSIX?

or just use substring_after( ... sub = '}' ), no?

Read only

thkolz
Contributor
0 Likes
1,907
DATA: v_string TYPE string VALUE '{12ZT-}716Ghdnsba'.

REPLACE PCRE '\{.*\}' IN v_string WITH ''.
Read only

touzik_itc
Active Participant
0 Likes
1,907

Or something like this

match( val = '{12ZT-}716Ghdnsba' regex = '[^}]*$' )