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

Question

Question

Pattern Matching Help Needed

asked on May 5, 2017 Show version history

Hello-Could you please help define a pattern matching to capture the following value;

 

Name: John Doe

 

Anything comes after the label " Name: " ,   and it will always be a space between first and last names

There is also a space between : and the first letter of first name

Thank you

 

0 0

Answer

SELECTED ANSWER
replied on May 5, 2017

The pattern I provided should leave out the "Name:" portion.  The parenthesis around \w+\s\w+ will isolate just the name for you.

Additionally, I made the spaces around the colon optional, that way you can have a space between Name and : and the first letter of the first name or not.

0 0

Replies

replied on May 8, 2017

I highly recommend the regex101 site, which is a much easier way to test and learn regex than the tester built into Laserfiche:

 

https://regex101.com/

 

I'd recommend this: Name\s*:\s*(.*)

 

It will capture EVERYTHING after the Name: , so it can capture hyphenated names and names of more than first and last name like Mary Smith-Jones and John S. Doe

1 0
replied on May 5, 2017 Show version history

Here you go

Name\s?:\s?(\w+\s\w+)

 

0 0
replied on May 5, 2017

Wesley, actually I do not need "Name: " to be captured.

Could you help modify so only the name is captured?

 

0 0
SELECTED ANSWER
replied on May 5, 2017

The pattern I provided should leave out the "Name:" portion.  The parenthesis around \w+\s\w+ will isolate just the name for you.

Additionally, I made the spaces around the colon optional, that way you can have a space between Name and : and the first letter of the first name or not.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.