As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Regular expression

From sasCommunity
Jump to: navigation, search

A Regular Expression is a way to characterize a pattern that you would like to match or validate. Regular expressions, sometimes referred to as regex or regexp, are particularly helpful when working with or manipulating messy or unstructured character strings.

What Can I Do With Regex?

  • Match a pattern
  • Extract the matching characters
  • Replace the matched characters with a new string (i.e. Find-and-Replace)

Regex in SAS

There are a number of ways to use regular expressions in SAS:

  • RX functions and call routines - Version 7
  • PRX functions and call routines - Version 9
  • Calling a script( e.g. Perl ) via the x or %sysexec statments
  • java.util.regex package via the Java Object - Version 9

Why Would I Want to Learn Regex?

While there are many tools that may do the work for you, there are also many reasons to learn regular expressions, including for pattern matching and searching large files. To read more on their importance, see the Wikipedia article.

There are many software packages that use or allow regular expressions.

Resources for learning Regex

Here are a few resources for learning regexes: