Regex to Match All Whitespace After Word -


i have strings this: "2015/08/this filename has whitespace .jpg"

i need match whitespace characters in strings. have "2015/08/ , end ".

i'm using sublime text 2 search , replace in sql db dump. i'm @ loss on how match. know can match whitespace \s, have no clue how contain groups.

as per comment, expression should work for string has same number of opening/closing double quotes:

\s+(?=(?:(?:[^"]*"){2})*[^"]*"[^"]*$) 

see demo here. look-ahead checking odd number of double quotes until end of file.

enter image description here

another approach define boundary \g , trim beginning of match \k:

(?:"\d{4}\/\d{2}\/|(?!^)\g)[^"\s]*\k\s(?=[^"]*") 

see demo

enter image description here

the regex finds match:

  • (?:"\d{4}\/\d{2}\/|(?!^)\g) - when substring starts numbers 2015/12/ or after successful match
  • [^"\s]*\k - matches characters not whitespace or " , omits them due \k operator
  • \s - here matches whitespace symbol
  • (?=[^"]*") - look-ahead checking presumably inside double quotes.

replacing spaces with, say, %20 results in:

enter image description here


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -