sonic208

regex finding characters after string doesnt work

4 posts in this topic

#1 ·  Posted (edited)

guys im going crazy why the hell is this regex not working ? the string look likes this

"blabla":{20},"resultCode":{"$":0}}}

and i want to have the value in the brackets, so the 0

$blabla = StringRegExp($sHTML,'([^}]+)',3)

$resultcode = StringRegExp($sHTML,'([^}]+)',3)

 

if a just got at least something saved  into the variable , but nothing i always get either a 0 or a 1 saved to the variable although there is some other number in the brackets

EDIT: now i get values added to the array but not in the way id like too .. :(

Edited by sonic208

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If they are all in that format then blabla will be in $atest[0] and ResultCode in $atest[1]

#include<array.au3>

$stest = '"blabla":{20},"resultCode":{"$":0}}}'

_ArrayDisplay(stringregexp($stest , "{*(\d+)}" , 3))

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#4 ·  Posted

Or this  :)

$string = '"blabla":{20},"resultCode":{"$":0}}}'
$val = StringRegExp($string, ":([^}{]+)", 1)
MsgBox(0, "", $val[0] )

 

Share this post


Link to post
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