开发者

Regular expression to Extract substring

开发者 https://www.devze.com 2022-12-09 23:23 出处:网络
I have a string like below url(\'/testProject/Images/Current/Universal/Styles/MasterPage_HomeIcon.gif\') repeat-x

I have a string like below

url('/testProject/Images/Current/Universal/Styles/MasterPage_HomeIcon.gif') repeat-x

How can I extract the substring starting from ' to end开发者_JS百科 ' ? I am using language as C#


If you want to check the surrounding text:

/url\(('[^']+')\)/

If the surrounding text does not matter:

/('[^']+')/

The [^'] selects all characters except the closing quote.


If you do not want ' to be part of the matched group:

/'([^']*)'/


Like this? (Assuming PCRE)

/(\'.*\')/
0

精彩评论

暂无评论...
验证码 换一张
取 消