javascript - Confused by regex -
so trying use googles regexextract
a1b2-dhsjdh472847xxx-fjdn rev : w25 i've tried:
regexextract (a1,"^(?: .{4}-).*(?:\s).*$") this gives me entire string , still capture non capturing group matched.
expected result:dhsjdh472847xxx-fjdn
note regexextract either returns whole match if there no capturing groups in pattern , capturing group contents if capturing group defined in pattern. ^(?: .{4}-).*(?:\s).*$ pattern matches whole string without capturing part, thus, not work expected. note non-capturing groups without quantifiers set on them or without alternation operators redundant. (?:\s) equal \s.
you may use
=regexextract(a20,"^[^-]*-(\s+)") pattern details
^- start of string[^-]*- 0+ chars other--- literal hyphen(\s+)- capturing group 1 (the text matched group output, rest omitted) matches 1 or more non-whitespace chars.

Comments
Post a Comment