Dgameman1 Posted March 25, 2016 Posted March 25, 2016 Here is the code I've got so far #include <array.au3> $string = "asdasdasdasday Name is Daniel dasdsdfg dfas" $Match = StringRegExp($string, '(?i)(.{4}?)name(.{4}?)', 1) $Match = $Match[0] & " " & $Match[1] ConsoleWrite($Match) This issue with this is that if I change the 4's to 30, then I get an error because the string isn't long enough for 30 characters behind and ahead. How can I change it to be UP TO 30 characters behind and ahead?
Dgameman1 Posted March 25, 2016 Author Posted March 25, 2016 Figured it out (?i)(.{1,30})name(.{1,30})
iamtheky Posted March 27, 2016 Posted March 27, 2016 $string = "asdasdasdasday Name is Daniel dasdsdfg dfas" $nCharsAround = 10 $sMatch = "Name" msgbox(0, '' , stringreverse(stringreverse(stringmid($string , stringinstr($string , $sMatch) + stringlen($sMatch), $nCharsAround)) & " " & stringreverse((stringinstr($string , $sMatch) - $nCharsAround < 1) ? (stringleft($string , stringinstr($string , $sMatch) - 1)) : (stringmid($string , StringInStr($string , $sMatch) - $nCharsAround - 1 , $nCharsAround))))) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
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