How to write regex expression to remove particualr string

chaituu chaitu
chaituu chaitu used Ask the Experts™
on
Hi,

How to write regex expression for below string to get the final output as

"d1a2227e-291f-4d82-8991-b9458b4ad0d3","fb48e632-3c85-483b-86b3-76f7a1c7eb25","93fa5301-29e2-4ef6-9353-686868686888"



input string= @Check:"workspace://SpacesStore/d1a2227e-291f-4d82-8991-b9458b4ad0d3" OR @Check:"workspace://SpacesStore/fb48e632-3c85-483b-86b3-76f7a1c7eb25" OR @Check:"workspace://SpacesStore/93fa5301-29e2-4ef6-9353-686868686888
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
HI,

pls try
workspace:\/\/SpacesStore\/

Open in new window

REgards
Top Expert 2016

Commented:
That's ONE input string?

Author

Commented:
That's ONE input string?

yes
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Top Expert 2016

Commented:
You might try something like this (where input string is 's')

        Pattern p = Pattern.compile("/([a-f0-9\\-]+)\"");
        Matcher m = p.matcher(s);
        while (m.find()) {
            System.out.println(m.group(1));
        }

Open in new window

Author

Commented:
its working.May i know the meaning of this expression?
Top Expert 2016
Commented:
It's just capturing the characters of those IDs only. More precise would be

        Pattern p = Pattern.compile("((?:[a-f0-9]+-){4}[a-f0-9]+)");
        Matcher m = p.matcher(s);
        while (m.find()) {
            System.out.println(m.group());
        }

Open in new window

Author

Commented:
what is the meaning of this ?:[a-f0-9]+-){4}  ???
Top Expert 2016

Commented:
Capture groups of lower case hex characters separated by hyphens
Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2018

Commented:
See the explanation section on the right-hand side of
https://regex101.com/r/L5FxH4/1
Top Expert 2016

Commented:
Sorry - let me be a little more precise:
Capture groups of lower case hex characters followed by hyphens four times (the remainder of pattern is explained by the first seven words [only] of this sentence)
Top Expert 2016

Commented:
:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial