Skip to main content
Solved

Text Between two Characters


marjan_nikoukar
Contributor
Forum|alt.badge.img+6

Hi. I need to know how can I get data between two characters.
I have an attribute like this:
10 12 Street (Main) Camnore
Firstly I need to get data between two characters ( ) and Secondly I need to convert it into two columns with this result:
10 12 Street Camnore
10 Main Camnore
Is StringSearcher is helpful? if yes how can I get this result?

I really appreciate your assistance

Best answer by joepk

Hi, do these RegExes work in your StringSearcher? 

 

(?<=\().*?(?=\)) This matches the word between parentheses (extracts ‘Main’)

\d+ This matches the first number of your string (extracts ‘10)

\w+$ This matches the last word of your string (extracts ‘Camnore’)

 

If you use 3 StringSearchers to extract these strings you can construct “10 Main Comnore” using a StringConcatenator.

You can use a StringReplacer replacing the RegEx \([^()]+\) to replace the ‘(Main)’ part with nothing, leaving you with “10 12 Street Camnore”

Hope this helps!

 

Edit: I am not familiar with US (?) addresses, so I'm not sure if this matches all your cases

View original
Did this help you find an answer to your question?

7 replies

danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • March 4, 2024

Hi @marjannikoukar 

 

I suggest you use the transformer StringSearcher with this Regular Expression: (?<=\[).*?(?=\])

 

You get the result into characters.

 

 


marjan_nikoukar
Contributor
Forum|alt.badge.img+6

Thank you for your reply danilo_fme
When I used that, I got same result as my Input. Do you have any idea?
Thank you for your time

 


danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • March 4, 2024
marjannikoukar wrote:

Thank you for your reply danilo_fme
When I used that, I got same result as my Input. Do you have any idea?
Thank you for your time

 

Please, could you share your Workspace?


marjan_nikoukar
Contributor
Forum|alt.badge.img+6

 danilo_fme The result in NotMatched is same as input like this:
10 12 Street (Main) Camnore


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • Best Answer
  • March 5, 2024

Hi, do these RegExes work in your StringSearcher? 

 

(?<=\().*?(?=\)) This matches the word between parentheses (extracts ‘Main’)

\d+ This matches the first number of your string (extracts ‘10)

\w+$ This matches the last word of your string (extracts ‘Camnore’)

 

If you use 3 StringSearchers to extract these strings you can construct “10 Main Comnore” using a StringConcatenator.

You can use a StringReplacer replacing the RegEx \([^()]+\) to replace the ‘(Main)’ part with nothing, leaving you with “10 12 Street Camnore”

Hope this helps!

 

Edit: I am not familiar with US (?) addresses, so I'm not sure if this matches all your cases


marjan_nikoukar
Contributor
Forum|alt.badge.img+6
joepk wrote:

Hi, do these RegExes work in your StringSearcher? 

 

(?<=\().*?(?=\)) This matches the word between parentheses (extracts ‘Main’)

\d+ This matches the first number of your string (extracts ‘10)

\w+$ This matches the last word of your string (extracts ‘Camnore’)

 

If you use 3 StringSearchers to extract these strings you can construct “10 Main Comnore” using a StringConcatenator.

You can use a StringReplacer replacing the RegEx \([^()]+\) to replace the ‘(Main)’ part with nothing, leaving you with “10 12 Street Camnore”

Hope this helps!

 

Edit: I am not familiar with US (?) addresses, so I'm not sure if this matches all your cases

Hi joepk. Thank you so much for your time and complete answer. I only have a problem.
When I use a StringReplacer replacing the RegEx \([^()]+\) to replace the ‘(Main)’ part with nothing, it’s not working.  Do you have any idea about it?


 


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • March 6, 2024

Yes, your StringReplacer is set to ‘Replace Text’, but you have to set it to ‘Replace Regular Expression’


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings