0

Can someone help me with the regular expression to find and select code inside a specific css class in eclipse for eg: I have a class:

.addContentLink {
    position: relative;
    left: 470px;
}

so I want to select code inside the opening and closing braces....thanks in advance.

2 Answers 2

1
 (?s).*?\{(.*?)\}.*?

Please see the demo

http://regex101.com/r/uU0kC7/1

Edited

(?s)\.addContentLink.*?\{(.*?)\}.*?

This will work for one specific class .But if there are multiple then a pattern would be needed.

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

8 Comments

thnaks for reply, but it doesnt select blocks with multiline code, and also where do i put the class name ie: ".addContentLink"?
which language are you using.You just have to pass the whole string and add multiline option. In python it would be like patter=.re.compile(r".*?\{(.*?)\}.*?",re.M) patter.match(your_string).groups()
i have a external css file in which i need to change code for all media queries...and i want eclipse to find all code blocks with specific css class name
it will select multiline as ?s does that.You can apply this over any file.
thanks buddy, but where do i mention the class name??
|
0

I appreciate the accepted answer, but I am adding this which will support line breaks too.

.*?\{([\s\S]*?)\}.*?

Link: https://regex101.com/r/rb4syz/1

Comments

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.