Regex "after and before word"

It seems like there is a discrepancy between my Regex editor and the one in UiPath. Can you help me with the below?

Input

McDonalds
Road 22

Lines

Coke 22
Sprite 33

Balance 55

Desired Output
I want everything between Lines and Balance (excluded). In this case:
Coke 22
Sprite 33

Simple pattern:
grafik

Value Specific pattern:
grafik

Please share more details on this with us of needed. What is different from expectations? Which pattern is used? Thanks

Sorry for not providing enough information :slight_smile:

I need the generic pattern, that extracts:
Coke 22
Sprite 33

and

Coke 22
Fanta 44
Sprite 33

from the two input strings

McDonalds
Road 22

Lines

Coke 22
Sprite 33

Balance 55

See you

and

McDonalds
Fanta 44
Road 22

Lines

Coke 22
Fanta 44
Sprite 33

Balance 55

See you

Coke 22
Fanta 44
do have a pattern of many letters(UpperCase/SmallerCase) SPACE many digits

but also still valid to Road 22

As long you will not

  • restrict all allowed values like Fanta, Coke, Sprite…
  • or restrict all not allowed values like Roead, Balance…

the unneeded Matches cannot defined within the pattern. Regex is not made for recognizing what is a coke (Beverage, Menu Card Item) or a Balance (Receip line item)

In case of the scenario can be fixed more on some constraints e.g with Blockslicing/detection (find all line items e.g. end) can be additional used for extracting the unknown from the middle (then also Tea 15)

1 Like

Again sorry for not being detailed enough.

I want to match “Fanta \d{2}” and it needs to be the one that lies between Lines and Balance:

McDonalds
Fanta 44
Road 22

Lines

Coke 22
Fanta 44
Sprite 33

Balance 55

See you

PS. Fanta and two digits can appear a lot in the string, but only once between Lines and Balance, and that’s the match I want.

@LauraMM - is this your expected output?

When you print if you see whitespaces, just use .trimstart and .trim which will strip all the whitespaces

1 Like

Thanks a lot for helping me. No, I need only the Fanta \d{2}, but it needs to be the one between Lines and Balance (the digits can vary).

This is what you asked Initially…

1 Like


and group:
grafik

2 Likes

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