Welcome Guest

Pages: 1
Regex not being recursive?
LouisMackey111PostJanuary 3, 2019, 13:27
Newbie
Posts: 14
Registered:
November 8, 2014, 19:45
Normal topicRegex not being recursive?

Hi,

I'm trying to place commas (well actually ⏃ as a place holder for a comma) in my composer field when I have (Royal) titles: for instance I have

John Winston Ono Lennon MBE (1940 — 1980) / Sir James Paul McCartney CH MBE (b.1942)

and I want it to end up

John Winston Ono Lennon, MBE (1940 — 1980) / Sir James Paul McCartney, CH, MBE (b.1942)

In my composer field, and I have the statement (where V9 will have the titles from a list with a Repeat statement)

Find all matches for regular expression "(.*)\ \V9(.*)" in field Composer, replace with "$1\⏃\ \V9$2" to field Composer, set state

it works for the last title found but not the first. Am I wrong in thinking that "all matches" tries again after a match till no more matches are found?

Just a little lost (as usual)
Thanks
Louis Mackey

2MR2PostJanuary 3, 2019, 13:40
Avatar photo
Administrator
Posts: 2083
Registered:
August 23, 2012, 19:27
Normal topicRe: Regex not being recursive?

Match All should replace all occurrences of a pattern in a string with the replacement patter. So a regexp of:

e

and a replacement template of:

XXX

will modify:

The best method

to be:

ThXXX bXXXst mXXXthod

Variables are treated as text and are not enumerated. For the above example what would variable 9 contain?

2MR2PostJanuary 3, 2019, 13:44
Avatar photo
Administrator
Posts: 2083
Registered:
August 23, 2012, 19:27
Normal topicRe: Regex not being recursive?

If variable 9 contains a list, you would have to use a Repeat statement to run over the RegExp for every element in the list. I'm pretty much at the limit of the variable/named variable substitution that I'm cramming into Apple's RegExp API.

LouisMackey111PostJanuary 3, 2019, 13:56
Newbie
Posts: 14
Registered:
November 8, 2014, 19:45
Normal topicRe: Regex not being recursive?

My Action looks like this (a ridiculously long list of Titles and the repeat)

Set Variable 8 to "CD<>"
Append "CBE<>" to Variable 8
Append "OC<>" to Variable 8
Append "OBC<>" to Variable 8
Append "MBE<>" to Variable 8
Append "OBE<>" to Variable 8
Append "OB<>" to Variable 8
Append "CI<>" to Variable 8
Append "CIE<>" to Variable 8
Append "KCIE<>" to Variable 8
Append "CSI<>" to Variable 8
Append "KCSI<>" to Variable 8
Append "GCSI<>" to Variable 8
Append "GCH<>" to Variable 8
Append "KCH<>" to Variable 8
Append "KH<>" to Variable 8
Append "KP<>" to Variable 8
Append "CH<>" to Variable 8
Append "KBE<>" to Variable 8
Append "DBE<>" to Variable 8
Append "GBE<>" to Variable 8
Append "ISO<>" to Variable 8
Append "OM<>" to Variable 8
Append "MVO<>" to Variable 8
Append "LVO<>" to Variable 8
Append "CVO<>" to Variable 8
Append "DCVO<>" to Variable 8
Append "KCVO<>" to Variable 8
Append "GCVO<>" to Variable 8
Append "DSO<>" to Variable 8
Append "CB<>" to Variable 8
Append "DCB<>" to Variable 8
Append "GCB<>" to Variable 8
Append "LT<>" to Variable 8
' The Most Ancient and Most Noble Order of the Thistle
Append "KT<>" to Variable 8
' The dignity of Knight Bachelor
Append "Kt<>" to Variable 8
Append "KG<>" to Variable 8
Append "LG<>" to Variable 8
Append "CM<>" to Variable 8
Append "1st Baronet<>" to Variable 8
Append "1st Marquis<>" to Variable 8
Append "1st Marquis of the Gardens of Aranjuez<>" to Variable 8
Append "CD<>" to Variable 8
' Fellow Royal Society of Literature
Append "FRSL<>" to Variable 8
Append "OC<>" to Variable 8
Append "OBC<>" to Variable 8
Append "ONM<>" to Variable 8
Append "AO<>" to Variable 8
Append "CC<>" to Variable 8
Append "GOQ<>" to Variable 8
Append "RDI<>" to Variable 8
Append "Ph◉D<>" to Variable 8
Append "OOnt<>" to Variable 8
' The Legion of Honour is the highest French order of merit for military and civil merits
Append "Chevalier de la Legion d'Honneur<>" to Variable 8
Append "Officer de la Legion d'Honneur<>" to Variable 8
Append "Commandeur de la Legion d'Honneur<>" to Variable 8
Append "Grand Officier de la Legion d'Honneur<>" to Variable 8
Append "Grand-Croix de la Legion d'Honneur<>" to Variable 8
' Order of Merit of the Italian Republic
Append "Cavaliere OMRI<>" to Variable 8
Append "Ufficiale OMRI<>" to Variable 8
Append "Commendatore OMRI<>" to Variable 8
Append "Grande Ufficiale OMRI<>" to Variable 8
Append "Cavaliere di Gran Croce OMRI<>" to Variable 8
Append "Cavaliere di Gran Croce Decorato di Gran Cordone OMRI<>" to Variable 8
' The Order of Prince Henry the Navigator is a Portuguese National Order of Knighthood
Append "GColIH<>" to Variable 8
Append "GCIH<>" to Variable 8
Append "GOIH<>" to Variable 8
Append "ComIH<>" to Variable 8
Append "OIH<>" to Variable 8
Append "CvIH<>" to Variable 8
Append "DmIH<>" to Variable 8
' National Order of Merit (France)
Append "Chevalier Ordre du Mérite<>" to Variable 8
Append "Officier Ordre du Mérite<>" to Variable 8
Append "Commandeur Ordre du Mérite<>" to Variable 8
Append "Grand Officier Ordre du Mérite<>" to Variable 8
Append "Grand-Croix Ordre du Mérite<>" to Variable 8
' Fellow of the Royal Society of Edinburgh
Append "FRSE<>" to Variable 8
' Ordre des Arts et des Lettres, Order of France
Append "Commandeur de l'ordre des arts et des lettres<>" to Variable 8
Append "Officier de l'ordre des arts et des lettres<>" to Variable 8
Append "Chevalier de l'ordre des arts et des lettres<>" to Variable 8
' Royal Designers for Industry, British Royal Society of Arts
Append "RDI<>" to Variable 8
' Austrian Decoration for Science and Art
Append "Decoration for Science and Art<>" to Variable 8
Append "Cross of Honour for Science and Art: First Class<>" to Variable 8
Append "Cross of Honour for Science and Art<>" to Variable 8
' Order of Australia
Append "AK<>" to Variable 8
Append "AD<>" to Variable 8
Append "AC<>" to Variable 8
Append "AO<>" to Variable 8
Append "AM<>" to Variable 8
Append "OAM<>" to Variable 8
' King's/Queen's Counsel (England)
Append "KC<>" to Variable 8
Append "QC<>" to Variable 8
Append "Jr.<>" to Variable 8
Append "Sr.<>" to Variable 8

' Call TitleSearch
Repeat With Variable 9 for the list in field Variable 8 (As found) string delimiter "<>" Run inline action 'TitleSearch' grouped

and the sub ACTION
Start Titlesearch
' Process Composer Field
Find all matches for regular expression "(.+)([\ ☺]\V9)\Z" in field Composer, replace with "$1\⏃$2" to field Composer
Find first match for regular expression "(.+)([\ ☺]\V9)(\ .+)" in field Composer, replace with "$1\⏃$2$3" to field Composer
Find last match for regular expression "(.+)([\ ☺]\V9)(\ .+)" in field Composer, replace with "$1\⏃$2$3" to field Composer
Find all matches for regular expression "(.+)([\ ☺]\V9)(\ .+)" in field Composer, replace with "$1\⏃$2$3" to field Composer

as you can see I've been experimenting to try to get the result I'm after

2MR2PostJanuary 3, 2019, 14:31
Avatar photo
Administrator
Posts: 2083
Registered:
August 23, 2012, 19:27
Normal topicRe: Regex not being recursive?

Well the Unicode characters are somewhat hurting my brain. However, I think I get the essence of what you're after.

You're only getting at most one match because your regexp is accumulating leading and trailing sequences.

For the source:

John Winston Ono Lennon MBE (1940 — 1980) / Sir James Paul McCartney CH MBE (b.1942)

If I do successive calls (with CH and then MBE as contents for v9), I get:

John Winston Ono Lennon, MBE (1940 — 1980) / Sir James Paul McCartney, CH, MBE (b.1942))

I've changed the regexp to be simply space\v9 (space - backslash - v9) and the replace template to be ,space\v9 (comma-space-backslash-v9).

My action is as follows:

Set Variable 8 to "CH<>MBE"
Set the Composer field to "John Winston Ono Lennon MBE (1940 — 1980) / Sir James Paul McCartney CH MBE (b.1942)"
Repeat With Variable 9 for the list in field Variable 8 (As found) string delimiter "<>" Run inline action 'Titlesearch'
Debug: Prompt \[Composer] UI

Start Titlesearch
Find all matches for regular expression " \v9" in field Composer, replace with ", \v9" to field Composer, set state

As the above only essentially searches for the variable content, replacing the regexp statement with the following does the same:

Replace " \v9" in the Composer field with ", \v9"

The simple Replace is probably far faster than the regexp.

Remember that the mailer strips backslashes 🙁 while the forum display does not 🙂

Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.021 seconds.