1

I am trying to write the regex to search the string

String :

{@CSS resources=",resources/css/page.css,/resources/css/global.css ," /}

Regex:

{@CSS resources=\s*"(.*?)"\s*\/}|(^,)|(,$)

Need to find leading and trailing commas with "resources"

3
  • \{@CSS resources=\s*",[^"]*"\s*\/} Commented Apr 18, 2017 at 10:41
  • are you trying to do the replace? Commented Apr 18, 2017 at 10:43
  • NO, I want to match any leading or trailing commas and spaces between {@CSS resources= and /} with in doube quotes (,resources/css/page.css,/resources/css/global.css) Commented Apr 18, 2017 at 10:48

1 Answer 1

1

You can use this regex:

{@CSS resources=\s*"(\s*,\s*)*(.*?)(\s*,\s*)*"\s*\/}

and replace with {@CSS resources="$2" /}

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

2 Comments

I want to match any leading or trailing commas and spaces between {@CSS resources= and /} with in doube quotes (,resources/css/page.css,/resources/css/global.css)
@BharathBhuvan That's what the first and third capture groups do !

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.