Split Input String, into Matches REGEX, and not results are found, But in Regex BUilder I can see the results

Hi Team,

I am using the regex to split the string. I am using Matches to see if I can find the instances of the regex matches.

As Shown in the screen shot, I am using Read text file to get the input string, then using Matches activity in which I am using certain regex into regex builder, and the required fields are being seen as shown in the figure.

But when i am running this module and using message box to print the count of the regex matches, it is always showing as ZERO!!!

I tried using qualifiers are “Exactly” and also “Atleast 1”, but still get 0 as total regex instances.

Please help me with it. Kindly let me know if more settings needs to be done in Matches activity.

Thanks and Regards,
@hacky

Hi @hacky

Set the flags like this
image

Hope this may help to solve your issue
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@Pratik_Wavhal

Thanks for your inputs!

But I am still getting Zero.
Please find the test file :- Test_File.txt (4.2 KB)

Regex:- “\|[a-zA-Z0-9]{3}\n”

Can you just read this file using Read Text file and then try to get me the count as shown in the figure above?

Regards,
@hacky

Hi @hacky

So as per this img
image

What exactly you want as the output ??
Can you write the exact output here

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@Pratik_Wavhal

Okay, So on a high level I want to read the text file and use the regex to separate the input text file input string into multiple sub strings.

So in this case, I was just wondering why is Matches not able to give me the count of the FOUND INSTANCES.

SO in this img, there are around 28 instances which are being highlighted using this text info and the above mentioned regex. But when I am just trying to get the count and print into message box, it always showns zero.
I mean if its not able to find any instance then why would it even show it in the regexBuilder.

Please help me with it.

Thanks and Regards,
@hacky

Because when you read the text file, the line doesn’t end in \n, but in \r\n.
Replace your regex with \|[a-zA-Z0-9]{3}\r\n+ and see if that returns your desired result.

3 Likes

@RobertD

This worked! thanks!!!

Can you please help me divide my strings with respect to the above mentioned regex?
Do you can any approach in mind to achive the same?

Hi @hacky

Below is the regex to extract all 28 Lines seperately
image

Hope this may help to solve your issue
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@Pratik_Wavhal

I am getting it like this, Can you please use this link to fix it and resend the link to me?

some lines are not included in some records.

KINDLY USE THIS REGEX : ^[a-zA-Z0-9].+(\d{3}|[a-zA-Z0-9])

Hi @hacky

Some of the fluctuations are bcz the whitespaces in between so sometimes it wont match even the Regex is right
Just check this now whether it works or not.

Hope this may help to solve your issue
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@Pratik_Wavhal

But in this case, the input string is changed right?

Input raw string itself is scatered between multiple lines once in a while, THATS the entire reason we are working with regex as a separator.

Hi @hacky

Bro its solved now atlast

Hope this may help to solve your issue
Mark as solution if this helps you and like it :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

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