d0n Posted July 22, 2009 Posted July 22, 2009 is there a way to look for match certain words that only show up some of the time? for example i have a pattern Jon is hit with arrow for 831 damage but some times it will say (Critical Hit) Jon is hit with arrow for 1831 damage The pattern right now will only catch the first example while not the second because of (Critical Hit) So far to get the first example i have (.*?).*?with\s*(.*?)\s*for\s*(\d+)
Authenticity Posted July 22, 2009 Posted July 22, 2009 #include <Array.au3> Dim $aStr[2] = ['Jon is hit with arrow for 831 damage', _ '(Critical Hit) Jon is hit with arrow for 1831 damage'] Dim $sPattern = '(?i)(?:\(.*?\)\s*)?(\w+).*?with\s*(\w+)\s*for\s*(\d+)' Dim $avMatch For $i = 0 To 1 $avMatch = StringRegExp($aStr[$i], $sPattern, 1) If IsArray($avMatch) Then _ArrayDisplay($avMatch) Next
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now