RegEx to String

I am RPA developer Newbie and I have trying to figure out how to use RegeX to isolate sections of a word and text document, using separate RegEx expressions. When i put the sample text into the RegEx wizard and input the formula it highlights the section(s) i am looking for. But, when i run the bot, i consistently get an error message, saying that the output is null. I have attached my RegEx equations and the subsequent Main file that i am using. If anyone can offer any assistance I would greatly appreciate it .

Mainfile
Main.xaml (255.2 KB)

.txt file that contains the document the RegEx is being applied to.testfilecharlie.txt (10.3 KB)

RegEx equations
regex equation.txt (662 Bytes) project.json (968 Bytes)

Hi @jbrown2019,
If your regex highlights only this one record then you need to assign it to output and use it like this:
regexOutput(0).Groups(0).ToString

1 Like

Good Morning Pablito,

I tried using the regexoutput(0).Groups(0).ToString and got the error below:

Can you offer any additional assistance ?

Is your matches activity returns only one thing or more results? Can you show example of text input and output of regex? You can use this site for better overview:

The matches activity returns only 1 result, the section that i am looking for. When input the complete sample word document into the regex 101, with the regex formula (?<=INTRODUCTION\n\n)(.*)(?=\n\nMAJOR) it highlighted the desired section.

@jbrown2019,
In regex attribute mark multiline as one of parameters. This should work:
image
Without this it can’t catch whole phrase as it’s not written in one line together so it returns empty record :wink:

2 Likes

Hi,

You could try regexoutput(0).groups(0).value.
For me this always works.

With kind regards

Pablito, i added the Regex options and i am still getting the same error. I am not sure if Uipath like my regex formula because it seems like a null value is continuously returned.

I tried your recommendation and it did not work. I provide my main file and the additional files that go along with that, could you look at what i did and let me know if you see something that i don’t see

this is another image of the error i am getting

Are you able to paste here text example so I could test it by myself?

Text example: ( i want to pull only the text under the section “Introduction”

Public Health Advisor, GS-0685-13

Job Code: 001120
Position Number: 101SP101796

INTRODUCTION

The employee serves as a senior public health advisor and provides consultative services to the most difficult and complex disease control programs or projects that have unusually demanding social, economic, cultural, governmental, and political conditions requiring the planning, development, and evaluation of matters of general precedent, extensive controversy, or wide coordination. The incumbent is responsible for performing unusually difficult assignments that affect populations domestically and/or internationally or public health programs that require advanced occupational expertise and judgment to support particularly complex program activities or very broad program applications on a continuing and frequent basis.

MAJOR DUTIES

Program and Administrative Management - __________%

Plans, develops, and implements public health programs in collaboration with local, State, tribal, territorial, national and international governments and various public, non-profit, and private and health-related organizations. Establishes systematic methods for program execution and advocacy that includes the identification of objectives, evaluation criteria, and legal and regulatory compliance requirements.
Serves as the principal program representative and provides program expertise, guidance, and leadership on unusually difficult and complex programs. Provides comprehensive technical, administrative, and management advice and guidance on program activities that are extremely broad and diverse and are carried out by a large staff usually organized in multiple operating echelons. Formulates program strategies including goals, priorities, operating policies, and evaluation methods and approaches. Carries out long range planning and evaluation.
Conducts assessments, compliance reviews and negotiates and approves corrective actions, as needed. Monitors program compliance requirements and recommends approval or disapproval of existing or proposed program activities or expansions. Prepares reports of findings and recommendations.
Reviews congressional and legislative actions; assesses impact on public health program activities, initiatives, and policies; and initiates action accordingly. When warranted, drafts testimonies, policies, responses to inquiries, and/or financial statements for use in hearings and executives reviews, and to address concerns by grantees, contractors, and other concerned citizens. Represents the program or function on intra- and inter-agency task forces, committees, etc.
Serves as a representative to professional organizations in order to gain cooperation from these groups. The incumbent must be persuasive in bringing about such cooperation and effective in negotiating problems and coordinating implementation of programs.

Budget, Cooperative Agreements, Contracts and Grants Management - __________%

Manages and oversees funding/budgets and a variety of grants, cooperative agreements, contracts, and other awards including initiation, administration, award, monitoring, evaluation, coordination, and close-out. Maintains a critical role with officials in formulating and implementing policy pertaining to the planning, management, and evaluation of a variety of grants, cooperative agreements, contracts, and other awards. Reviews and approves applications for grant assistance, proposed revisions, supplemental requests, and/or other changes. Formulates policies, plans, and programs to ensure fund expenditures. Assesses activities to determine funding requirements, needs, and statutory and regulatory compliance. Recommends alternatives for accomplishing and meeting program objectives. Exercises approval authority for authorized expenditures and fund appropriations.

Performs other duties as assigned.

Thanks for input data. I tested it and seems that in this particular case you’ve found a bug :slight_smile:. Seems that regex wizard in activity have a problem with proper "\n" recognition. Instead of this be sure that you regex attributes are like below:
image
And for each "\n" there should be "\r" in the front. So your regex formula should look like this:
"(?<=INTRODUCTION\r\n\r\n).+(?=\r\n\r\nMAJOR)"
So the output is:


Thanks for being patient. I reported this bug as well :slight_smile:

2 Likes

Pablito It worked . Thank you very much . How did you ever figure this out ?

1 Like

I’ve used this pattern:
image
And double clicked on the output in output pane to check what it returns. This was the result:
image

1 Like

Well I’ll be . Thanks for showing this newbie some tricks . This RegEx is pretty amazing . Again THANK YOU

1 Like

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