Regular expression to Extract substring

后端 未结 3 446
你的背包
你的背包 2021-01-25 12:11

I have a string like below

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

How can I extract the substri

相关标签:
3条回答
  • 2021-01-25 12:52

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

    /'([^']*)'/
    
    0 讨论(0)
  • 2021-01-25 12:54

    Like this? (Assuming PCRE)

    /(\'.*\')/
    
    0 讨论(0)
  • 2021-01-25 12:56

    If you want to check the surrounding text:

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

    If the surrounding text does not matter:

    /('[^']+')/
    

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

    0 讨论(0)
提交回复
热议问题