In google spreadsheets, using regular expressions, how can I count the characters, numeric only, that are between the first hyphen of a string (from left to right) and the first comma after the hyphen? The correct thing would be to count only the characters "2, 3, 4 and 5", that is, 4 characters.
CodePudding user response:
You can use the regex "-.*?(\d*).*?,"
to get the number out with REGEXTRACT(A2, "-.*?(\d*).*?,")
and then use LEN
to get the length:
=LEN(REGEXTRACT(A2, "-.*?(\d*).*?,"))
CodePudding user response:
Try this
=REGEXEXTRACT(REGEXEXTRACT(A2, "-. ?,"), "[0-9] ")