Removing space from string with regex -
i can find spaces in following string:
"____input abc" << please note there 4 spaces @ beginning of string
using regex:
[a-z] [a-z]
how can replace"t f" "tf" , "m a" "ma"? guess have use groups don't remember how. advice appreciated.
p.s. please note there 4 spaces @ beginning of string don't want remove them.
depending on language using, should have "replace" function
you have use capturing group, :
([a-z]) ([a-z])
http://www.regular-expressions.info/refcapture.html
and use function them in pattern want :
newstring = oldstring.replace("([a-z]) ([a-z])", "\1\2")
\x reference xth group of parenthesis
Comments
Post a Comment