following situation:
item.
content => "This is a 48593 test"
title => "the title"
item.
content => "This is a 48593 test 3255252"
title => "the title"
item.
content => "This 35542 is a 48593 test"
title => "the title"
item.
content => "i havent exactly 5 digits 34567654"
title => "the title"
this is my current item in the console of pipes
no i want to replace "content" with "the last match of a number that has exactly 5 digits. wanted result:
item.
content => "48593"
title => "the title"
item.
content => "48593"
title => "the title"
item.
content => "48593"
title => "the title"
item.
content => ""
title => "the title"
is there a way to do this in pypes 2?
please comment if something is unclear
Use the regex module like this:
In item.content replace
(.*)
withX $1
In item.content replace
.*\b(\d{5})\b.*
with$1
In item.content replace
X .*
with nothing (leave field empty)Here's an example pipe
Some Explanations
\d{5}
finds exactly five digits\b
word boundaries, so that numbers with more digits are not foundX
at the beginning marks strings where the regular expression doesn't match to delete them afterwards*
is a greedy operator.