cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

extract substring using regex

Hi there,

 

I'm trying to extract a substring for text that is variable - both the string and the substring change, but while the structure of the string changes, the pattern of the substring remains the same - it just appears in different places depending on the string.

 

Example: Two strings

sdflkjsdlkjsdflksdjfldsfkj@123BOB23sdflkjsjdlfkjsdfkj

sdflkjsddjfldsfkj@4567SUE45sdflkjsjdlfkjsdfkjasdasdasd

 

I want to extract -123BOB23  and -4567SUE45 from each string using the same method.

I can use IsMatch to determine if the pattern exists with regular expressions, but IsMatch just checks for the pattern, it doesn't extract it for me.

 

I can't rely on Left/Mid/Right as the last digit of what I'm extracting changes, making it impossible to determine where it ends using those methods.

 

Ideally I need something like IsMatch to provide a way to both match the pattern and extract the substring for me....

Any ideas?

 

Kind regards,


R

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: extract substring using regex

Hi Russel_Thomas,

 

I am afraid currently there might not be such a function can be used to extract substring.

 

May you consider to submit a request at PowerApps ideas Forum for this function:
https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

I will report it on my side and keep an eye on this function, I will back to you if I got any updates.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Community Support Team
Community Support Team

Re: extract substring using regex

Hi Russel_Thomas,

 

I am afraid currently there might not be such a function can be used to extract substring.

 

May you consider to submit a request at PowerApps ideas Forum for this function:
https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

I will report it on my side and keep an eye on this function, I will back to you if I got any updates.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Re: extract substring using regex

Anonymous
Not applicable

Re: extract substring using regex

Have you guys comes up with any solution to this problem yet?

Super User
Super User

Re: extract substring using regex

I realise this is a really old post but in case someone is searching for this, the answer is to use named groups like so.

image.png

In this example, this is the formula we would use.

Match( "sdflkjsdlkjsdflksdjfldsfkj@123BOB23xx", "(\d+)(?!.*\@)(?<EmailSuffix>.*)" ).EmailSuffix

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,457)