Jump to content
UBot Underground

Regex - Match All Until First Space


Recommended Posts

I want to be able to grab only the first word (any characters)
not sure whats going on, but No matter what I try i keep getting the second words after the space, but when i try the code in a regex builders says it works---- please help

set(#business_name,"J1ck$ Bean Stalk","Global")
set(#business_name_trimmed,$replace regular expression(#business_name,"^\\s*([a-zA-Z0-9]+)",""),"Global")

Result = Bean Stalk
Result I want = J1ck$

Thanks

Link to post
Share on other sites

try

set(#business_name,"J1ck$ Bean Stalk","Global")
set(#business_name_trimmed,$replace regular expression(#business_name,"\\s.*",""),"Global")
alert(#business_name_trimmed)
Link to post
Share on other sites

That works as intended, the reason you are having issues is because you used $replace regular expression and so it replaced the text you told it to. If you wanted to find that text then you would use $find regular expression (which is what the Regex Builder is using that is why you saw that)

 

Hope this clears it up and gets you the intended result.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...