-1

I am having a string and I want to get a specific value from it.

@string = "[ewqewe]wwerc:[value1]&31545415151|erertrtc:[value2]&nbmnbmn|uiuoiuoioioc:[value3]s:[value4]pupup[vfdvdfv]fbdbdbbdbddbdbdbdbc:[value5]&uiiouops:[value6]"

I just want to extract a value that is coming after c: and s: inside[ ] but it must exclude [vfdvdfv] and [ewqewe] because it not coming with c: and s:

%%[

    var @ss @pattern @value1, @value2, @value3, @value4, @value5, @value6

    set @ss = '"[ewqewe]wwerc:[value1]&31545415151|erertrtc:[value2]&nbmnbmn|uiuoiuoioioc:[value3]s:[value4]pupup[vfdvdfv]fbdbdbbdbddbdbdbdbc:[value5]&uiiouops:[value6]"'


set @pattern = '^.*[ewqewe]wwerc:(.*)&31545415151|erertrtc:(.*)&nbmnbmn|uiuoiuoioioc:(.*)s:(.*)pupup[vfdvdfv]fbdbdbbdbddbdbdbdbc:(.*)&uiiouops:(.*)'

    set @value1 = RegExMatch(@ss, @pattern, 1)

    set @value2 = RegExMatch(@ss, @pattern, 2)

    set @value3 = RegExMatch(@ss, @pattern, 3)

    set @value4 = RegExMatch(@ss, @pattern, 4)

    set @value5 = RegExMatch(@ss, @pattern, 5)

    set @value6 = RegExMatch(@ss, @pattern, 6)

]%%

value1:%%=v(@value1)=%%<br>
value2:%%=v(@value2)=%%<br>
value3:%%=v(@value3)=%%<br>
value4:%%=v(@value4)=%%<br>
value5:%%=v(@value5)=%%<br>
value6:%%=v(@value6)=%%<br>

Can Someone correct this so that it will give result like

value1:value1

value2:value2

value3:value3

value4:value4

value5:value5

value6:value6

  • If you could update your question with any attempts you've already made -- functional or not, it'll help us help you. – Adam Spriggs Aug 26 '19 at 15:51
  • Hi Adam, i have updated my question will you please correct it. – James Aug 27 '19 at 7:59
2

Yes. You will need to use Regular Expressions, however (regex).

Have a look at the Ampscript RegEx Documentation.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.