About EasyMorph Tutorials & Examples Web-help

Regex capture groups


#1

Would like to be able to calculate a new field based on a regex capture group from another field.

For instance, let’s say I had a field named “HTML” with HTML in it, with a variety of HTML tags. But I’d like to pull out the title from the title tag. I’d like to create a transformation step that I put in something like “<TITLE>(.*)</TITLE>” (yes the regex expression could be improved) and then it fills in a new field “TITLE” with those capture groups. So if row one had <TITLE>My Webpage</TITLE> then the TITLE field would be “My Webpage” and if the next row had <TITLE>Another page</TITLE> then the TITLE field would be “Another page” etc.


#2

Maybe I’m missing something, but it sounds like the “Regular expression” transformation does exactly this. Is there a case where it doesn’t do what is needed?


#3

How would I pull out just what’s in between the open and close title tag?

I can see how to pull in the ENTIRE match, but I only want the CAPTURE GROUP. But it doesn’t seem that’s how the regular expression transformation works:

Instead of this I just want the title field to have “lkajsdf”, “lakjsdafalskjdf”, etc.


#4

Oh, now I see what you are talking about. Point taken.


#5

Will be added in 3.8 with three new capture modes: Matches only, Groups only, Matches and groups.


#6

Great!