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+)") 

enter image description here

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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -