function extractNumberFromString pString
  put ".*([0-9]+).*" into myRegex
  local x,y
  if matchChunk(pString, myRegex, x, y)
  then return char x to y of pString
  else return pString -- unmodified string to leave field as-is.
end extractNumberFromString

on example
  -- field contains: " (Size: 100ml; )"
  -- it should contain just the value: 100
  put extractNumberFromString(fld "Product") into fld "Product"
  -- e.g. replaces " (Size: 100ml; )" with 100
  -- if it fails then it leaves string intact.
end example


________________________________
From: FlexibleLearning <ad...@flexiblelearning.com>
To: metacard@lists.runrev.com
Sent: Sunday, May 8, 2011 1:14:19 PM
Subject: RE: Re: setting itemdel

A regex would certainly be better. As it requires a degree of coding
proficiency that was not evident when the question was initially raised, I
provided a solution to suit.

Would you like to give us your matchtext solution rather than a copied
generic?

Hugh Senior
FLCo


Alain Farmer wrote:

Best solution for this would be a GREP pattern. :)

Example:  .*([0-9]+).*

PS: use metacard's replaceText syntax.

Al

> replace " (Size: 100ml; )" with " 100" in fld "Product"
>
>
> But you have different 'size' values. This removes the
> non-numeric characters...
>
> ? set the itemDel to TAB
> ? repeat with n=1 to num of lines of fld "Product"
> ? ? replace "(Size: " with "" in item 2 of line n
> of fld "Product"
> ? ? replace "ml;)" with "" in item 2 of line n of
> fld "Product"
> ? ? replace "g;)" with "" in item 2 of line n of
> fld "Product"
> ? end repeat
>
>
> Hugh Senior
> FLCo


_______________________________________________
metacard mailing list
metacard@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/metacard
_______________________________________________
metacard mailing list
metacard@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/metacard

Reply via email to