Link to home
Start Free TrialLog in
Avatar of xenium
xenium

asked on

REGEXEXTRACT to extract a subsection of text

Hiya, I recently came across the REGEXEXTRACT function in google docs but there is no documentation. I think it will do what i want though, that is to split a windows file path into parts based on searches eg:

C:\user\Dropbox\property\maintenance & repairs\open\oddj smp1 slight leak through new window (normal).jpg

extract "open" with the rule: the text between the last two backslashes
extract "oddj" with the rule: from the last backslash to the next space
extract "smp1" with the rule: from "oddj" until the second space
extract  "slight leak through new window" with the rule from "smp1" until the full stop (or space before if there is one)
extract  "normal" with the rule text between the last set of brackets

Can anyone help with some or all of these? The rules can be bent as long as they give the correct answer in any similar example.

Thanks a million!
Avatar of xenium
xenium

ASKER

Avatar of xenium

ASKER

Item 3 extract "smp1" , the following almost does this except the bounding conditions are included in the result, how do i remove these?

=REGEXEXTRACT(fullpath, trade & "\w*\s")

Gives result: oddj smp1
I need just: smp1

Thanks again
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xenium

ASKER

Great thanks, that works straight off (bar typo in function name which is REGEXEXTRACT)

I'll have a look at the rest later as I have to dash now, but looks like that would work for a few of the points above. Meanwhile if you have any tips on any that maybe trickier feel free to post. cheers
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xenium

ASKER

Thanks that works a treat! I'll have a closer look tomorrow and try to wrap up the rest too.
Avatar of xenium

ASKER

This is powerful stuff, but i'm still struggling, could you help with the first and fourth cases too?

Maybe also some tips how to "read" such expressions. eg i think the following is the case for the last example, can you confirm/correct, also how the logic ties together..

Look for any character except closed parentheses:
[^)]
Return all characters except closed  parentheses:
([^)]*)
Look for any number of characters:
.*
Look for open/closed parentheses:
\(
\)

Open in new window


Thanks again!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xenium

ASKER

Thanks a lot for your help. That does the job for now. If i need to dig further I'll repost new questions.
Avatar of xenium

ASKER

Many thanks for your help!