Home > Blockchain >  REGEX - Find first word of a string of text
REGEX - Find first word of a string of text

Time:03-26

i'm looking for a regex to pick the fist word of a textbox in a game.

Example:

James
Hello my friend, how are you?

I would like to know a regex that picks "JAMES" from that example. So it has to pick the first word, and only if there is a linebreak after it.

How would you recommend me to do it?

I already tried ^. : but it only works whenever the name has a colon at the end (James:)

CodePudding user response:

Maybe this REGEXP would help you

(.*[\n\t])

You can test it on this web page enter image description here

If you are looking for a regex that has only one word then you can use ^\w $

enter image description here

  • Related