Application Development 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: 

Regular expression to find a string that begins with > and ends with }

RachamallaKiran
Participant

Hi all,

May i know how to write regular expression to get the string that starts with > and ends with }

ex: in string : data>/ab/cd/peter} ; prop>/site/sing/perl};

want the string `>/ab/cd/peter}` and `>site/sing/perl}`.

i tried with this but not knowing how place a condition that starts with >

my findings:

(\/(\w+)\/)*(\w+)(@*)(\w+)(~*)((\w+)?)\/(\w+)\}

Regards,

kiran rachamalla.

1 ACCEPTED SOLUTION

BaerbelWinkler
Active Contributor

For others happening upon this thread, a colleague recently pointed me to a neat demo-program with which REGEX expressions can be tested. It also includes a link to the help documentation:

DEMO_REGEX_TOY

As the name of the program implies you can really play with REGEX with it!

Here is how it looks like for the example given:

Cheers

Baerbel

13 REPLIES 13

RachamallaKiran
Participant

Found the Answer ([^\>\}]*)\}

Regards,

kiran rachamalla

BaerbelWinkler
Active Contributor

For others happening upon this thread, a colleague recently pointed me to a neat demo-program with which REGEX expressions can be tested. It also includes a link to the help documentation:

DEMO_REGEX_TOY

As the name of the program implies you can really play with REGEX with it!

Here is how it looks like for the example given:

Cheers

Baerbel

matt
Active Contributor

That's really useful. I've been using online REGEX checkers, but you're never sure they're following the same rules as the SAP kernel.

All in the documentation 😉

matt
Active Contributor

I'm sorry, you've lost me now. 😉

horst_keller
Product and Topic Expert
Product and Topic Expert

DEMO_REGEX and DEMO_REGEX_TOY are in fact part of the documentation's example library in package SABAPDEMOS and of course mentioned in the text

https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenregular_expres...

They are around quite long

https://blogs.sap.com/2009/09/10/abap-geek-14-regular-expressions-made-easy/

They were created exactly for the reasons you give above. In the beginning, DEMO_REGEX_TOY had some flaws regarding the line breaks, that are fixed meanwhile.

matt
Active Contributor

In my defence. I read documentation when I have an issue with how things work.

When I need to check a regex, my first response is to Google "online regex checker". It's not "oh, I must read the abap documentation just in case someone has decided to write a regex checker in abap and has made it part of the abap documentation."

When it comes to my bedtime story, my wife prefers to read me the classics, or Sci fi. She's not so keen on Abap documentation... 🙂

0 Kudos

Uh... and I thought you were joking! As in: Documentation? Nobody who posts on this site is familiar with that concept (apart from Horst).

Then I also noticed I fell into the old ABAP docu trap of copy-pasting the URL and just getting the top level link. Horst's link was the one I meant to post, have corrected mine.

horst_keller
Product and Topic Expert
Product and Topic Expert

But what to do else?

It is exactly as you said "someone has decided to write a regex checker in abap and as part of the abap documentation".

That was me, and I am documentation writer. What to do else?

matt
Active Contributor
0 Kudos

I don't think there is anything else.

matt
Active Contributor
0 Kudos

I was joking.

0 Kudos

Just wondering: do these Demo-programs/packages qualify as "hidden gems" and should perhaps be highlighted more to make people aware of them? There's just so much "stuff" in a SAP-system that items like these easily fly under people's radar:

A quick search for the demo package found this older blog post by a "former member":

https://blogs.sap.com/2013/07/04/useful-abap-packages-for-demo-programs/

Would perhaps a new blog post along those lines - properly highlighted - help raise awareness?

Cheers

Baerbel