Jump to content

Stringregex between pattern´s


Recommended Posts

Hey there,

I´m struggling around for an hour now to figure out, how to cut a simple string between 2 words in a google response. 

It looks like this:

"description": "Im a string and I don´t know how long I can be!",
          "boundingPoly": {

I want to use a Stringrex. My bad try looks like this: 

$aResult = StringRegExp ($sOutput,"(?i)(?s)(\Q) description(.*?) boundingPoly(\E)",3)

But this seems to be on a totaly wrong way. Thanks for everybody!

Edited by lordsocke
Link to comment
Share on other sites

#include<string.au3>

$str = '"description": "Im a string and I don´t know how long I can be!",' & _
          '"boundingPoly": {'

$s1 = '"description":'
$s2 = ',"boundingPoly"'

msgbox(0 , '' , _StringBetween($str , $s1 , $s2)[0])

also, probably just this for the regex, but you need to clarify whether the quotes appear as they do in the question, or if they appear like the one in your regex wrapping description and boundingpoly (as i assumed in the above answer)

$str = 'description: "Im a string and I don´t know how long I can be!",' & _
          'boundingPoly: {'

msgbox(0, '' , StringRegExp ($str,"description:(.*?),boundingPoly",3)[0])

 

Edited by iamtheky

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

Link to comment
Share on other sites

7 hours ago, mikell said:

better like this

if better means 'in a fashion that takes a penalty to accommodate unsanitized input....'   :ninja:

*you really should probably write it that way and not nest things that can explode.

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

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...