You are viewing limited content. For full access, please sign in.

Question

Question

Pattern Matching Request

asked on June 4, 2024 Show version history

I am using Quick Fields to add street name metadata to a form.  The form data looks like the following:

STREET NAME: MAIN STREET

or

STREET NAME: MAIN STREET & STATE STREET

or 

STREET NAME: MAIN STREET, STATE STREET & INDEPENDENCE AVENUE

I have tried a few patterns on my own but always end up grabbing some data, but not all.  What is a good pattern to use that will get each street name on its own street name field??

Thank you!

0 0

Answer

SELECTED ANSWER
replied on June 4, 2024 Show version history

It's going to depend on your data and on more of the form than you've shown us. 
Does that field ever wrap to multiple lines?
Are the values well-known or is it literally any street name? 
Do street names ever have colons, commas, and/or ampersands? 
Are there always 1, 2, or 3 street names?
Do they always use the pattern A & B when there's two streets and A, B & C when there's three streets?
Is the whitespace consistently a single space?

Given what you've shown us, I'd recommend using two patterns and processing it in two (or more) stages.  But your needs may vary a lot based on answers to the questions above.
 

Stage 1: Get the street names
STREET NAME: ([^:\r\n]+)
What does this do?
It strips the STREET NAME: text and makes the next pattern easier to create and reason about.

Stage 2: Break up the street names into multiple values (use the All matches option)
\s*([^,&]+){1,}
What does this do?
\s* says "ignore any whitespace before the first word"
(...){1,} says "find one more of the pattern within the parentheses"
[^,&]+ says "find one or more characters that are NOT caret or ampersand"
This causes the regex engine to collect all letters up to a caret or ampersand and make that a capture group.  Then, do that again, and if there's at least one non-caret, non-ampersand character, start a second capture group (until a comma or ampersand is reached).  Keep repeating this until the end of the string.

3 0
replied on June 4, 2024

I am going to give that pattern a try and see how it goes, but let me answer those questions here as well:

 

Does that field ever wrap to multiple lines? NO
Are the values well-known or is it literally any street name? ANY STREET NAME. (COULD BE CT, LN, PRKWY, ST, RD.)
Do street names ever have colons, commas, and/or ampersands? IT'S ALWAYS GOING TO BE AS LISTED ABOVE.
Are there always 1, 2, or 3 street names? YES
Do they always use the pattern A & B when there's two streets and A, B & C when there's three streets? YES
Is the whitespace consistently a single space? YES, BUT THAT ALSO DEPENDS ON HOW QUICKFIELDS READS THE FORM AND INTERPERTS THE SPACES.

0 0

Replies

You are not allowed to reply in this post.
replied on June 4, 2024

I am going to give that pattern a try and see how it goes, but let me answer those questions here as well:

 

Does that field ever wrap to multiple lines? NO
Are the values well-known or is it literally any street name? ANY STREET NAME. (COULD BE CT, LN, PRKWY, ST, RD.)
Do street names ever have colons, commas, and/or ampersands? IT'S ALWAYS GOING TO BE AS LISTED ABOVE.
Are there always 1, 2, or 3 street names? YES
Do they always use the pattern A & B when there's two streets and A, B & C when there's three streets? YES
Is the whitespace consistently a single space? YES, BUT THAT ALSO DEPENDS ON HOW QUICKFIELDS READS THE FORM AND INTERPERTS THE SPACES.

You are not allowed to follow up in this post.

Sign in to reply to this post.