Using regular expressions in a script

Viewing 2 reply threads
  • Author
    Posts
  • March 6, 2021 at 7:40 AM #43699

    Victor Warner
    Participant

    I have a text field. It contains names (usually two or three words).

    Is it possible to extract only the first word in a script field in way using regular expressions? (eg ^(\S+) (.*)$ or ^(.+?) (.*)$).

    March 6, 2021 at 2:04 PM #43702

    Brendan
    Keymaster

    I imagine you can just use the regular JavaScript regular expression support:

    https://www.w3schools.com/js/js_regexp.asp

    But I haven’t tested it myself.

    March 6, 2021 at 4:57 PM #43703

    Sam Moffatt
    Participant

    Correct, the standard built in Javascript engine works within the scripts.

    If you check out my repo there is a match example and a replace example (also includes a sample of creating a RegExp object as well if you look up a few lines).

Viewing 2 reply threads

You must be logged in to reply to this topic.