I want to extract text before first comma (first and last name) from strings like:
John Smith, RN, BSN, MS Thom Nev, MD Foo Bar, MD,RN
I tried with regex:
(.*)\s(.*),\s
but this doesn't work for all situations. How to achieve this?
Select a blank cell, and type this formula =LEFT(A1,(FIND(" ",A1,1)-1)) (A1 is the first cell of the list you want to extract text) , and press Enter button. Tips: (1) If you want to extract text before or after comma, you can change " " to ",".
The 0-9 indicates characters 0 through 9, the comma , indicates comma, and the semicolon indicates a ; . The closing ] indicates the end of the character set. The plus + indicates that one or more of the "previous item" must be present.
i) makes the regex case insensitive. (? s) for "single line mode" makes the dot match all characters, including line breaks.
\\. matches the literal character . . the first backslash is interpreted as an escape character by the Emacs string reader, which combined with the second backslash, inserts a literal backslash character into the string being read. the regular expression engine receives the string \.
Match everything from the beginning of the string until the first comma:
^(.+?),
How about: yourString.split(",")[0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With