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.
another approach define boundary \g
, trim beginning of match \k
:
(?:"\d{4}\/\d{2}\/|(?!^)\g)[^"\s]*\k\s(?=[^"]*")
see demo
the regex finds match:
(?:"\d{4}\/\d{2}\/|(?!^)\g)
- when substring starts numbers2015/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:
Comments
Post a Comment