On Fri, 23 Feb 2001 Gary Rathbone <[EMAIL PROTECTED]> wrote:

> I'm sure this is simple, but I've got a Friday evening mental block.
> 
> I've got an HTML template file, in which are codes such as:
> *name*
> *email*
> *phone*
> 
> All I need to do is extract a list of these codes from the HTML template.
> So, basically extract any string that starts with "*" and ends with "*".
> 
> Any quick funky regex solution would be great, otherwise I'll have to do it
> char by char (and I know there's a better way...)

regex is probably overkill for this problem.  A couple of other ideas:
1) Set the item delimiter to "*" and get items 2, 4, 6, etc.
2) The following will work if the tags are delimited by white space:
  repeat for each word w in <your string>
     if char 1 of w is "*" and char -1 of w is "*"
     then # do whatever
  end repeat
3) if you insist on using regex, the following will work *if* you're
   sure that only one such tag will appear in the chunk of text you
   pass to it (because MetaCard's regex only does greedy matches):
  if matchtext(<your text>, "\*(.*)\*", it) then #"it" has the match in it

Lots of ways to skin this particular cat...
   Scott

> TIA
> 
> Gary Rathbone

********************************************************
Scott Raney  [EMAIL PROTECTED]  http://www.metacard.com
MetaCard: You know, there's an easier way to do that...


Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to