Jump to content

Recommended Posts

Posted

Hey all,

I'm having a bit of trouble with regex and hopefully you can help me out.

So the initial string comes in as part of an HTML source...

"3. third<br> 4. fourth<br> 5. fifth<br> 8. eighth<br> 9. ninth<br> 10. tenth<br> 12. twelfth <br> 14. fourteenth"

From here I'm trying to pull out all the words... however, it's pulling out "br" as well...

Here's the regex I'm using.

$aResults = StringRegExp($allText, "[[:alpha:]]+", 3)

Just to make sure I'm getting my point across.... the array my autoit code retuns is:

third
br
fourth
br
fifth
br
eighth
br
ninth
br
tenth
br
twelfth
br
fourteenth

I'm pretty sure the results I'm looking for have something to do with the conditionals in RegEx.... but after tons of reading I still can't figure it out. :D

Posted (edited)

This works.

#include<array.au3>
$array = StringRegExp("3. third<br> 4. fourth<br> 5. fifth<br> 8. eighth<br> 9. ninth<br> 10. tenth<br> 12. twelfth <br> 14. fourteenth", "[0-9]{1,2}. ([a-z]{5,10})<br>", 3)
_ArrayDisplay($array)
Edited by Hawkwing

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Posted

I'm trying to make sure I don't get the numbers in there... but I could see

"([a-zA-Z]+)<br>"
helping... I'd just have to trim the last 4 characters for every element in the array... thanks.

Posted

You didn't test the code. The numbers and <br> are just to make sure its getting the right string. The only thing it puts into the array is what is in the group. Groups are defined by parentheses, and if the flag is 1 or 3 it captures the groups and puts them into an array.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Posted

To learn the basics of stringregexp, you should read neogia's guide, helped me a lot a couple weeks ago.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

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
  • Recently Browsing   0 members

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