» VL: Regular Expressions
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

VL: Regular Expressions

Finally,

we have regular expressions in vl. What the? Here is the gist:

Regular expressions provide a powerful, flexible, and efficient method for processing text. The extensive pattern-matching notation of regular expressions enables you to quickly parse large amounts of text to find specific character patterns; to validate text to ensure that it matches a predefined pattern (such as an email address); to extract, edit, replace, or delete text substrings.

via docs.microsoft

vvvv beta comes with the RegExpr (String) which is quite handy but doesn't cover all cases. vux provides a RegExpr (String Replace) via the addonpack, which adds the "replace" case, but there is more. So let's see what we got in shop for vvvv gamma:

Pattern matching

The simplest case: Just figure out if a given string matches a given pattern:

Is the input a valid email address?

Replacing by pattern

Sometimes a simple replace by string is not enough. See this example where we're stripping a string of all occurences of html-tags, ie. replacing them with nothing.

Removing html tags from a string

Splitting by pattern

Sometimes a split by string is not enough. See this example where we're splitting a string by any multiple occurances of lowercase letters:

Splitting a string at a pattern

Finding occurences by pattern

Find all substrings that match a given pattern. Imagine a string that contains many dates written in the format "Month Day, Year" and you want to get all of those:

Extracting all occurences of dates in the input string

RegexOptions

The last pin on all of the above nodes is the Options enum pin. Since this enum allows multiple selections (ie. a bitwise combination of its member values), there is a RegexOptions node that allows you to set multiple of the options at the same time:

Choosing multiple regex options at the same time

And more

The above should cover most typical usecases. But regular expressions can do even more. Luckily with vl you're not restricted to what we decide to provide for you, but you have direct access to the full set of functionality .NET regular expressions offer. For example there are situations where you want to use the static operations that .NET provides instead of the process nodes shown above. If so, simply choose "Advanced" in the nodebrowser and, navigate to the "Regex" type and choose the static operations from there...

Static regex operations available among the advanced nodes

Available for testing in latest alphas now!

joreg, Wednesday, Feb 20th 2019 Digg | Tweet | Delicious 5 comments  
tonfilm 20/02/2019 - 22:57

and whenever you are stuck with your RegEx pattern, this page helps: https://regex101.com/

cyril 26/02/2019 - 22:23

you can test your regex with the online testerhttps://extendsclass.com/regex-tester.html

tonfilm 27/02/2019 - 17:58

@cyril interesting, haven't seen this page before. where do you see the advantages of it over regex101?

cyril 27/02/2019 - 19:21

@tonfilm there is a graphic explanation of the regular expression (instead of a textual explanation on regex101)

tonfilm 01/03/2019 - 18:54

ah, thanks for that. it appears after you entered the regex, that's why i didn't see it before. they do a good job visualizing the expression. thanks for the link!

  • 1

anonymous user login

Shoutbox

~18h ago

joreg: vvvvTv S02E01 is out: Buttons & Sliders with Dear ImGui: https://www.youtube.com/live/PuuTilbqd9w

~7d ago

joreg: vvvvTv S02E00 is out: Sensors & Servos with Arduino: https://visualprogramming.net/blog/2024/vvvvtv-is-back-with-season-2/

~8d ago

fleg: hey there! What's the best tool for remote work? Teamviewer feels terrible. Thanks!

~21d ago

joreg: Last call: 6-session vvvv beginner course starting November 4: https://thenodeinstitute.org/courses/ws24-5-vvvv-beginners-part-i/

~1mth ago

joreg: Missed the last meetup? You can rewatch it here: https://www.youtube.com/live/MdvTa58uxB0?si=Fwi-9hHoCmo794Ag

~1mth ago

theurbankind: When is the next big event, like node festival ?

~1mth ago

~1mth ago

joreg: Join us for the next vvvv meetup on Oktober 17th: https://visualprogramming.net/blog/2024/25.-vvvv-worldwide-meetup/

~1mth ago

joreg: 6 session beginner course part 2 "Deep Dive" starts January 13th: https://thenodeinstitute.org/courses/ws24-5-vvvv-beginners-part-ii/