ramirez
ramirez

Reputation: 43

How to search then select a string among double quote in JAVA?

I have a variable named MyText in type of String as below:

"XYZ_abcdefgh..."

Note that abcdefgh... means that we don't know exactly what is it (simply say: it changes).

Now I want to select all of XYZ_abcdefgh... by this mean and put it in another variable like MyExportedText:

SELECT ALL STRINGS BETWEEN DOUBLE QUOTE WITCH STARTS WITH 'XYZ'

Thanks.

Upvotes: 1

Views: 97

Answers (2)

Gowtham
Gowtham

Reputation: 1597

try this regex to validate your string 

/^(?:[XYZ]{3,})([a-z]*)$/g

for reference check this link
   https://regex101.com/r/cV8xL2/1  

Upvotes: 1

manfcas
manfcas

Reputation: 1951

Take a look at Java capturing groups. Essentially you can enclose part of the regex in round brackets to "capture" them and extract them from the input String.

Upvotes: 3

Related Questions