Regular expression for string and pick the exact match

Hi All,

([A-Z].[A-Z]\d+.SFR)|([A-Z].[A-Z][0-9]\d+.SFR)|([A-Z].[A-Z][0-9]\d+[A-Z].SFR)|([A-Z].[A-Z]*[0-9]\d+ -.SFR)
Above expression is my regular expression for matching the multiple pattern of strings.
image
image
pdf_sfr This is the variable capturing the “1468 SFR” but it should capture the “Any characters ends with SFR” Example.:- A-12345 SFR, PAC-A0123-SFR.
Whatever it scans at the beginning its picking that, how to change the expression.
What changes I need to do.
Please help me.

Thanks,
Lakshmi

Hey @lakshmi.mp

Sounds possible.

Can you provide the Expected Output with some information about the pattern/what to expect/what you want.

In the meantime is this pattern what you need?

Cheers

Steve

Hi @Steven_McKeering ,
This is the sample from excel and stored into output data table. and need to pick.
sfr
1468 SFR PHOTO_9e000
C-Z01468- ONOFF
C-Z01468-ZZZ111
C-Z01400-LLO
C-Z01468-MODULE
C-Z01468-REPAIRED
C-Z01468- PARTS
C-Z01168-SFR
C-Z00068-SAA
C-Z00068-TAAA
C-Z00033-TEST_9c001
1468 - SFR
The names having “Any character ends with SFR” i.e, “*.SFR”. Here its picking
image
It should pick
image
Expected output patterns:
A-789654 SFR, A-Q12345-SFR, DDD-BN4455_SFR, WWW 78955_SFR, V 963852-SFR

Thanks,
Lakshmi

Hi @lakshmi.mp ,

Try Checking with the Expression in the Link Below :

Also, If you do not have any other criteria for this, we can also try with the below :

.+SFR$

1 Like

Hi @supermanPunch ,
I tried the expression but its not capturing.
Its blank
image
In excel data is present but not extracting its showing blank.

Thanks,
Lakshmi

@lakshmi.mp , Could you let us know what was the method used ? Are you using Matches Activity ?

Hey @lakshmi.mp

Take a look at this Regex Pattern and let me know if it’s correct.

Cheers

Steve

1 Like

Hey!

Try this

System.text.RegularExpressions.Regex.Match(InputStringVariable,".*SFR$").ToString

Reference:

Try this and let me know

Regards,
NaNi

hi @supermanPunch ,
image
I am not using matches, Excel data into output Dt and assigning reg expression to pdf_sfr variable.
in msg box filename is displayed and that variable is passed to click activity. Making click as dynamic.
.+SFR$ => this expression also not captured showing blank.
What changes I need to do.

Thanks,
lakshmi

@lakshmi.mp ,

I think it’s better not to use Output Datatable to generate the Datatable as String, as it also includes commas as separators and may also provide some unexpected outputs.

Could you let us know what is the Data that you are using from the Datatable. Could you save the Output from Output Datatable Activity into a text file and send it here, it will be faster to understand what is the actual data and what should be the logic to extract it.

@supermanPunch ,
Data scrapping data will be stored into excel and consists of list of file names. And that excel data is stored into output data table and performing the regex operation.

Hey!

Do we need to get the data which is ending with -

C-925303-SFR-

If yes we can try this:

System.text.RegularExpressions.Regex.Match(InputStringVariable,"[A-Z][A-Z0-9 -_]+SFR(-)*$").ToString

Which is given by @Steven_McKeering

Or do we want to get the only end with SFR

C-L25254-SFR

If only Ends with SFR

You can try the above mentioned Expression

Regards,
NaNi

2 Likes

@THIRU_NANI ,
System.text.RegularExpressions.Regex.Match(InputStringVariable,“.*SFR$”).ToString
I tried but showing blank.
System.Text.RegularExpressions.RegEx.Match(Sfr_dt,“.*SFR$”).ToString
Not extracting. In excel and text file data is writing but not extracting.

Regards,
Lakshmi

Hey!

Could you please show me the expression which assigned to the pdf_sfr variable?

Are you passing the variable?

Can you debug it and check the values in Immediate or Local Panel?

will get to know whether we are getting the data or not…

Regards,
NaNi

@THIRU_NANI ,
System.Text.RegularExpressions.RegEx.Match(Sfr_dt,“([A-Z].[A-Z]\d+.SFR)|([A-Z].[A-Z][0-9]\d+.SFR)|([A-Z].[A-Z][0-9]\d+[A-Z].SFR)|([A-Z].[A-Z]*[0-9]\d+ -.SFR)”).ToString
Now data extracted with my old expression, which i mentioned at beginning.
It worked.
Thanks,
Lakshmi

1 Like

@lakshmi.mp ,

Could you check the below Workflow :
RegexMatches_SFR.xaml (7.6 KB)

The Below was the regex expression which matched :

.+(SFR)\r?\n?$

2 Likes

Hi @supermanPunch ,

Thank you for providing the solution.

Regards,
Lakshmi

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.