We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

REGEX_Match return index

danBrow
5 - Atom

Hi all,

 

I have a problem similar to this silly example:

 

I have a text in the field [a]:

"hello how are you would you like to buy a car no thanks"

 

I'm looking in this field [a] for a word [x] next to another [y] like this

^.*(?:buy)\W+(?:\w+\W+){0,5}?(?:car)([\w+\W+])*

 

In a generic way I'm doing this:

REGEX_Match([a],"^.*(?:"+[x]+")\W+(?:\w+\W+){0,5}?(?:"+[y]+")([\w+\W+])*"

 

As a return I get the true value,

 

I need to receive the index of the word where the match occurred, in this example I need to receive the number 9.

 

how do i receive this number?

 

Thanks in advance to anyone that can help!

2 REPLIES 2
jrgo
14 - Magnetar

Hi @danBrow 

 

Try this formula

 

 

CountWords(
REGEX_REPLACE([a],"^(.*)(?:"+[x]+")\W+(?:\w+\W+){0,5}?(?:"+[y]+")([\w+\W+])*", '$1')
) + 1

 

 

jrgo_0-1608219347503.png

 

danBrow
5 - Atom

Hi

worked perfectly

thank you so much!

Labels
Top Solution Authors