Dashboard > APATAR USER GUIDES > Apatar User Guides > Sample Regular Expressions
  APATAR USER GUIDES Log In | Sign Up   View a printable version of the current page.  
  Sample Regular Expressions
Added by Alex Khizhnyak, last edited by Alex Khizhnyak on Apr 08, 2008  (view change)
Labels: 
(None)

This guide contains a few examples of regular expressions that you can use in the RegExp and Match RegExp functions.

Sample Examples

To get part of a field value before the first space:

(.*?)[\s].*

Example: Field contains 'Mike A Smith'. Apply this expression to get 'Mike'

To get a part of a field value after the first space:

.*?[\s](.*)

Example: Field contains 'Mike A Smith'. Apply this expression to get 'A Smith'

To get a part of a field value after the last space:

.*[\s](.*)$

Example: Field contains 'Mike A Smith'. Apply this expression to get 'Smith'

To get a part of a field value between the first and last space:

.*? \s {1}([\w\d\W]*) \s {1}.*

Example: Field contains 'Mike A Smith'. Apply this expression to get 'A'

To get the last n number of symbols from a field value:

.*([\w\W]{n})$

Example: Field contains '123No%34ab' and you need just '34ab' (the last 4 characters). Apply

.*([\w\W]{4})$

In the above examples '\s' can be replaced with other symbols depending on your data format. Example:
\t for 'tab'
\, for comma
- for dash
etc.

If your field values might contain various symbols you can include them all in the following way:

[\s\t\,\-]

Example, phone numbers in your database have different formats, like 111 222 4444 and 777-888-9999 and you need to get just the area codes your regular expression should be

(.*?)[\s\-].*

This way the resulting records will only contain 111, 777 etc.


See Also

     Pre-built DataMap

     Related forum post

     RegExp Function

     Match RegExp Function

Site running on a free Atlassian Confluence Open Source Project License granted to Apatar Data Integration (ETL). Evaluate Confluence today.
Contact Administrators