Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I have an input string like below

AB-0001234/00005-Testing My Regex hereAB-0004567/00007-Second Testing of my regex


and the output what I need is as below

-Testing My Regex here

-Second Testing of my regex


What I have tried:

I tried this regex

AB-[0-9]{7}\/[0-9]{5}


This gives me an output as

AB-0001234/00005

AB-0004567/00007


But i need exactly other strings other than these two (negation scenario)

Please help
Posted
Comments
honey the codewitch 10-Nov-21 11:54am    
Can you post several example strings, with example matches you'd like to see?

List several variations of this (including one with no matches)

And then below each one, list on a separate line each substring you'd like matched.


AB-0001234/00005-Testing My Regex hereAB-0004567/00007-Second Testing of my regex
--- matches ----
AB-0001234/00005
AB-0004567/00007
Second
Testing

(assuming you also wanted to match Second and Testing - i know you don't, i'm just trying to give you an example)

Anyway, make at least 4 of those, including one with no matches, and I bet you'll have a better time getting an answer.
Jo_vb.net 10-Nov-21 18:12pm    
Why using regex here?

You could use "AB-" to split the input string into lines

AB-0001234/00005-Testing My Regex here
AB-0004567/00007-Second Testing of my regex

then remove the 16 characters left (using strings.right or something like that)
and you would get

-Testing My Regex here
-Second Testing of my regex

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900