0

I have a column called path like below. I want to extract the sub strings 'AMERICANS','APAC','EAME' from each row. I am hence looking for a Regex which can do this for me. I am not very good at Regex. Can anyone please help me with this ? I need a Java Regex

Path

F:\Email Alias\AMERICIANS\Americas - Team
F:\Email Alias\AMERICIANS\Americas - Territory
F:\Email Alias\AMERICIANS\Americas- Market
F:\Email Alias\APAC\APAC - Market
F:\Email Alias\EAME\EAME - Team

Required:

AMERICANS
AMERICIANS
AMERICIANS
APAC
EAME

Thank You.

1
  • Regular expressions return true or false... you will have to split your string at every "/" and chop that into an array. You have provided a minimum of detail and that is why I keep my answer this short - I am not willing to do more work than you ;) Commented Nov 17, 2014 at 10:21

1 Answer 1

1

The below regex would match the strings you want.

[^\\]+(?=\\[^\\]*$)

DEMO

i think you need to escape the backslash one more time in qregularexpression.

Regular Expression:

[^\\]+                   any character except: '\\' (1 or more
                         times)
(?=                      look ahead to see if there is:
  \\                       '\'
  [^\\]*                   any character except: '\\' (0 or more
                           times)
  $                        before an optional \n, and the end of
                           the string
)                        end of look-ahead
Sign up to request clarification or add additional context in comments.

1 Comment

FYI, it appears the regex flavor is Java, not QRegularExpression. I've retagged it, but your double-escaping advice still applies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.