setting itemdel

Alain Farmer alain_farmer at yahoo.com
Fri Aug 5 22:33:00 CDT 2011


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 <admin at FlexibleLearning.com>
To: metacard at 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 at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/metacard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/metacard/attachments/20110805/04a6a473/attachment.html>


More information about the metacard mailing list