RegEx Again 
Author Message
 RegEx Again


I have my preferences file laid out like this (example):


Now I have this code to retrieve the data inside of the <bla> </bla> tags
(for both). This is a method I have made, before this method is executed, I
have retrieved the data from the file. The option string is the tag string I
want to search for and the data is the files complete data.

Function Retrieve(option as string, data as string)
  dim rg as RegEx
  dim myMatch as RegExMatch
  dim tempdata as string
  rg = new RegEx
  rg.SearchPattern = "<" + Option + ">.*</" + Option + ">"
  myMatch =
  If myMatch <> nil then
    tempdata = myMatch.SubExpressionString(0)
    msgbox "Sorry, but the selected preference option could not be found!"
  end if
  return tempdata
exception err as RegExException
  MsgBox err.message
End Function

For some reason I can't get it to work. I'm thinking that the search string
is wrong and it's probably the most likely explanation. Can anybody help me

Chris Willis

Sat, 18 Sep 2004 21:15:56 GMT  
 RegEx Again


> <Option1>thedatagoeshere</Option1>
> <Option2>mydata</Option2>
> <Option3>
>   rg.SearchPattern = "<" + Option + ">.*</" + Option + ">"

This will work fine if the value of the variable Option is right. Clearly
it isn't. RB includes a de{*filter*}; use it to help you here. m.


      *** REALbasic: The Definitive Guide! 2nd edition! ***

Mon, 20 Sep 2004 06:08:07 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Scheme vs ML again and again and again and again

2. Scheme vs ML again and again and again and again

3. grep regex to ruby regex...

4. Python regex / libc regex interactions

5. Regex++ or other Regex lib for Fortran?

6. 'SQL Server Login': Again, again, ...

7. APL and J (again and again)

8. APL and J (again and again) (long)

9. Re-inventing hot water again and again

10. tcltest processes subdirectory again and again - Why?

11. Newsgroup access again, good to see you all again

12. How to make a command run again and again until it sees a certain pattern


Powered by phpBB® Forum Software