User Tools

Site Tools


transformations:regexp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
transformations:regexp [2018/08/15 14:59] – created dmitrytransformations:regexp [2021/07/19 02:22] (current) – [Examples] craigt
Line 1: Line 1:
-===== Regular expression =====+{{ transformations:RegExpAction.png}} 
 +======REGULAR EXPRESSION====== 
 +Category: Transform / Advanced \\
  
-This action creates a column with values that match a pattern specified using a [[https://en.wikipedia.org/wiki/Regular_expression|regular expression]].+\\  
 +=====Description===== 
 +This action creates a column with values that match a pattern specified using a [[https://en.wikipedia.org/wiki/Regular_expression|regular expression]].\\
  
-**Modes**+\\  
 +=====Use cases===== 
 +A Regular Expression ("RegEx") is typically used to match values based on patterns or combinations of characters, numbers, symbols, and spaces that common "find" or "replace" functions (which use static values with wildcard characters) can't work with.
  
-  *//First match only// - for each value find only it's first match (if any). Ignore other matches. +Confirm the existence of values in a strict, predetermined format:  phone numbers, zip codes, email addresses, etc.
-  *//All matches// - for each value find all possible matches. If there is more than 1 match then insert additional row(s) into the resulting dataset.+
  
-===Example===+Validate that values fall within specific formatting parameters, e.g., a specific number of letters, numbers, and symbols in a required order.
  
-TableBefore+Check for alternate spellings of keywords, e.g., "color" vs. "colour"
 + 
 +RegEx can be used to replace a pattern of characters with another value or pattern.\\ 
 + 
 + 
 +\\  
 +=====Action settings===== 
 +^Setting^Description^ 
 +|Source column|Select the column to evaluate the values in.| 
 +|Regular expression<sup>*</sup>|Select the regular expression pattern to match to.  | 
 +|Case insensitive|When checked, text case is not taken into account when evaluating matches. 
 +|New column name|Enter the name of the new column that will hold the match results. 
 +|Mode|Select whether to return the first match only, or all matches.  See the "Mode options" table, below.| 
 +|If not matched|Select what value is returned when a match is not made.  Options //Keep original value//, //Make empty//, or\\ //Default to// (and enter either a static value or expression to be returned - select whether //It's an expression// or\\ //It's a text or number//.)| 
 +\\  
 +====Mode options==== 
 +^Option  ^Description 
 +|First match only|Only the first match to the pattern will be returned. | 
 +|All matches (may create new lines)|All matches found will be returned.  This will create a new row for each match. | 
 +|Capture mode |This option appears when //All matches// (above) is selected.  Select the method of capturing\\ the matched values.  Options:  //Matches only// ( ), //Groups only// ( ), //Matches and Groups// ( ). | 
 + 
 +\\  
 +=====Remarks===== 
 + 
 +EasyMorph uses the [[https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference|.NET regex language]]. 
 + 
 +While most "find" and "replace" functions can use wildcard characters to allow for a //single values// (?) or //any number of values// (*), they can't differentiate letters, numbers, spaces and symbols like RegEx can.  Use RegEx when not only the //number// of characters is important, but also the //types// of characters.\\ 
 + 
 +RegEx can be set to detect one or more occurrences of the search pattern within a given value.\\ 
 + 
 +\\  
 +=====Examples===== 
 +**Example:** Find phone numbers that match pattern ''(XXX)XXX-XXXX'' where X is any number. 
 + 
 +**Source table:**
 ^Phone number ^ ^Phone number ^
 | 1234567890    | | 1234567890    |
Line 17: Line 56:
 | 123-456-7890  | | 123-456-7890  |
 | (123)4567890  | | (123)4567890  |
 +\\ 
 +**Action parameters:**
 +> Source column is "Phone number"
 +> Regular expression is ''^\(\d{3}\)\d{3}-\d{4}''
 +> New column name is "Matches"
 +> Mode is "First match only"
 +> If not matched "Make empty"
  
-Goal: find phone numbers that match pattern ''(XXX)XXX-XXXX'' where X is any number. 
-Solution: Use regular expression ''^\(\d{3}\)\d{3}-\d{4}''. If not matched make empty. 
  
-TableAfter+\\  
 +**Result table:**
 ^Phone number   ^ Matches  ^ ^Phone number   ^ Matches  ^
 | 1234567890    |  | | 1234567890    |  |
Line 28: Line 73:
 | 123-456-7890  |  | | 123-456-7890  |  |
 | (123)4567890  |  | | (123)4567890  |  |
 +
 +\\ 
 +=====See also=====
 +
 +  * [[transformations:replace|Replace]]
 +  * [[syntax:functions:regexmatch|Functions:  RegExMatch()]]
 +  * [[syntax:functions:regexreplace|Functions:  RegexReplace()]]
 +  * [[syntax:functions:isregexmatch|Functions:  IsRegexMatch()]]
 +
 +
  
transformations/regexp.1534359552.txt.gz · Last modified: 2018/08/15 14:59 by dmitry

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki