1

How to retrieve the quoted value of a property.

suppose you have some expression like:

[html:text property="pqrs" styleClass="text" style="width:200px"].

And now i want to retrieve the value of property, styleclass and style ie "pqrs", "text" and "width:200px" respectively.

Can you guys please help me in this.

thanks a lot.

2 Answers 2

2

If you just want the text in quotes, a non-greedy match should work:

".*?"
Sign up to request clarification or add additional context in comments.

2 Comments

can you please write the matcher method that will return the quoted string using your expression. Thanks a lot
@Kuri - sorry, I've never written a non-trivial java program. If you need more detail, hopefully someone will come here and answer your question. I came here via the [regex] tag.
1
(\w+)\=\"(.*?)\"

The first capture group (\w+) gives you the attribute name, and the second capture group uses a non-aggressive operator to match things inside quotes.

3 Comments

if you can please write down the expression with the matcher and pettern method that should be used, will be a great help.
Thanks i got the answer, your expression works. Implementation using java code: String property =(string)="\"(.*?)\""; Pattern startingPattern = Pattern.compile(property); if(match.find()){ System.out.println("found"); for(int j=0; j<match.groupCount(); j++){ System.out.println(match.group(j)); }
Sorry, my Java is also a bit rusty. But you sure should know how to create a regex and execute it, otherwise you probably shouldn't be using regex's in the first place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.