litzinger Posted September 3, 2019 Share Posted September 3, 2019 (edited) Hello, I am making a website archiving program, however, I was wondering one simple thing that I don't get cause I'm new to regex I want to preform the following with regex: $readdata = _StringBetween(_INetGetSource($incrementchar &$incrementnum), 'data="', '"') I am trying with regex see below(but it doesnt seem to work at all) $regex2 = '/data=(["'& "\'])(.*?)\1/" $readdata = StringRegExp(_INetGetSource($incrementchar &$incrementnum), $regex2, 0) my conditional statement for $readdata is as shown below(but never gets executed) If IsNumber($readdata) = 1 Then Please help! How do I get the stringregex to operate like _stringbetween Edited September 3, 2019 by litzinger Link to comment Share on other sites More sharing options...
BrewManNH Posted September 3, 2019 Share Posted September 3, 2019 Why are you using IsNumber? Just check the return of the function directly, you only get a 1 or a zero, so just check to see if it's 1 without the IsNumber. I'm not sure if the return from StringRegExp is a numeric one, or the string "1", but might be the issue. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
mikell Posted September 3, 2019 Share Posted September 3, 2019 (edited) It's quite different. _StringBetween is used to get occurences of strings, while StringRegExp with flag 0 (default) is used to check something and returns true/false (match/no match) So if you just need to check if there are some data (or not) between data=" and " , then this could work $txt = 'something data="some data here" something else' If StringRegExp($txt, 'data="([^"]+)') Then Msgbox(0,"", "yes") $txt = 'something data="" something else' If not StringRegExp($txt, 'data="([^"]+)') Then Msgbox(0,"", "no") [^"]+ means : "one or more non-quote characters" Edited September 3, 2019 by mikell comment Link to comment Share on other sites More sharing options...
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