Jump to content

StringRegExp pattern help


Recommended Posts

Hi everyone. I'm trying to make a pattern that only returns anything between < and >. It could be anything, a word a number, a symbol, etc. So far I have (?i:\<[[:print:]]*\>) which works sort of. It returns everything between < and > but it also returns everyting outside it as well. I've been using the source of the autoit homepage to test. As an example I want <title> but I get <title>Autoit Script Home Page instead. I've tried (?i:\<[0-9a-z='"\s]*\>) which seems to work perfectly but I can't get it to work in SciTE because I need to use quotes to specify the pattern and if I do it cuts off at the set of quotes inside the pattern. Can anyone help?

Link to comment
Share on other sites

$regexp = StringRegExp("somestring", "(?i)<(.*?)>", 2)

this should work

It returns an array of matches

stringregexp is very well documented onthe help file

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

I know it is, that's how I got the pattern I had. I've been using flag 3 and the pattern you gave works pretty well. I changed it to (<.*?>) to include the < and > . This is only my second or third time using StringRegExp so I think I'm lucky I got as far as I did on the pattern I had. Thank you for the help.

Link to comment
Share on other sites

Just as a tip: When you are expecting the quotes to be in a string replace " with \x22 in your regex. It's not required because there are other work-arounds but I've found it to be the safest so far.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...