R regex to parse token after @ also with no additional tokens in string -
I have a problem parsing the address in the text string. The usual address will be "@edder token token token" or "@edder token token / NTOn".
string & lt; - c ("@ address token token token", "@ address token token / ntoken") gsub ("^ \\.? @ ([A-z0- 9_] {1,25}) [^ a-z0- 9 _] +. * $ "," \\ 1 ", string) is correctly parsed
[1]" address "Address" So far, in some cases the address string will be the only token, then regex @
string & lt; - c ("@ address token token token", "@ address token token / ntoken", "@address") gsub ("^ \\.? @ ([A-z0- 9_] {1,25}) [ ^ A-z0- 9 _] +. * $ "," \\ 1 ", string) # [1]" address "" address "" @ eddy " one-token How to instruct regex to manage the case
In some cases address string The only token will be, then the address will return with the regex @
Because there is no match in that situation.
Just make a small difference:
Convert [^ a-z0- 9_] + in [^ a-z0- 9_] ? to make it optional ^ \. @ ([A-z0- 9_] {1,25}) [^ a -z0-9 _] ?. $$ this is
Comments
Post a Comment