arraysregexstringdata-extractionparsehub

Regex: Keep last word after text


Tommy Hilfiger Men Teal Blue Analogue Watch TH1791293_BBD

I need to split this and keep the last part i.e

TH1791293_BBD

The issue is that the part before the target string i.e

Tommy Hilfiger Men Teal Blue Analogue Watch

Can be of varying length.

Summary: I need to split the text using spaces and keep the last part of the array. Additional constraint: I need to do it in a single line without being able to save the object in a variable(something like this):

a= $e.split(" "); output= a[a.length()-1]

Any solution to this problem is welcome. I've just started using Parsehub for data parsing.


Solution

  • With Extract tool, you may use

    (\S+)$
    

    Here,

    Note you should use the capturing group, see ParseHub Help Center reference:

    You must use captures "()" for any text you want included in your results. Optionally, you can turn on "extract all occurrences". This will make the extract command return a list of matches.