- Use Edit Column -> Add Column based on this column
- In GREL use the `match` function with a regular expression
Unlike `find` the `match` function requires you to write a complete match from the whole cell content - essentially it silently puts a ^ at the start of your expression and a $ at the end.
To 'capture' the bits of the expression you want you can use the usual regular expression capture groups with parentheses ( and )
The `match` function captures these into an array, and you can access the bits of that array and store them.
This is probably easier to show with an example. Lets imagine cell with the content "This is a match TERM match". The GREL:
value.match(/This is a match ([A-Z]+) match/)
will give you an array with a single entry - the word TERM. To store the content in a cell, you need a string (or number/date) not an array - so you need to do a bit more GREL to get to a string -e.g.
value.match(/This is a match ([A-Z]+) match/)[0]
The [0] extracts the first thing in the array generated by `match` - which is the word "TERM"
The find function works in a very similar way and you could use:
This would also result in an array containing a single entry with the word "TERM". But because find will find all matches to your pattern in the cell you have to be careful - a very similar expression:
Would find two matches in the example string I gave "T" and "TERM" - so you'd have an array with two matches instead of one.
Sorry this seems like a complicated explanation for a simple question!
If you need any additional help please supply a specific example of the starting content of the cell and the desired captured content and I can try and give you a more specific piece of GREL that will work
Owen