Find upper letter regex

Hi,

Which RegEx experssion can I use to check each row in Excel file to find row that does not match the pattern: β€œName Surname” and fix it as in attached pciture:
Excel4

Hello

I might have a solution for you…

Please provide a full sample (de-identified)?

I am assuming they have a capital letter at the start and lowercase for the remaining?

To add a space between, try this pattern:
(?<=[a-z])(?=[A-Z])
THen insert a " "
Regex101.com

You will also need to add an IF condition to handle when there is no match.

To remove spaces, you could try this pattern:
^\s*
Then replace with - β€œβ€
Regex101 link

2 Likes

You can directly Trim the Cell Value before any other operators.

1 Like

Hi @Steven_McKeering

Thank you for your responce. Do you mean like this?

RegEx

1 Like

Hello @Apple1,

No use Matches Activity and pass the above pattern

2 Likes

Hello

To insert a space:
Try this in an Assign activity:
System.Text.RegularExpressions.Regex.Replace(INSERTYOURVARIABLE, β€œ(?<=[a-z])(?=[A-Z])”, β€œ ”)

To clear the excessive spaces:
Try this in an Assign activity:
System.Text.RegularExpressions.Regex.Replace(INSERTYOURVARIABLE, β€œ^\s*”, β€œβ€)

For more information about Regex - check out my Regex MegaPost which has a working demo you can download - (no replace activities though).

1 Like

Hi @Apple1

Below is the solution which will solve your query :-

Regex.Replace(row(0).ToString.Trim,"\s+"," ").Split(" "c)(0)+" "+Regex.Replace(row(0).ToString.Trim,"\s+"," ").Split(" "c)(1)

Just the below double quotes space you have to add :-
image

Below is the workflow for the same :-
Pratik.xaml (9.7 KB)
Apple.xlsx (8.3 KB)

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

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

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