The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2013, 10:09:01 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Can one of you experts help me out with this REGEX?  (Read 3133 times)
tommytx
Expert
****
Offline Offline

Posts: 102


View Profile WWW
« on: September 21, 2010, 11:02:59 AM »

Example one.
<button tabindex="1" type="submit" name="U2F.sdGVkX18xN.TM:0NDE1MyrfgTOsvyQEhy5WAmmTpTJHwFrCl5-X:WjDLXzfZdMI9" value="Continue">Continue</button>

Example Two.
<button type="submit" name="U2FsdGVkX180MjgyN:DI4MtrQcIzzMPmJ4VYQMHXXBpo8:CK5wQO_AxyypP_.6bh0M7" value="Continue" tabindex="1">Continue</button>

I need to pull out nothing but the actual value for name... as below.. it changes value and length...each time.
U2F.sdGVkX18xN.TM:0NDE1MyrfgTOsvyQEhy5WAmmTpTJHwFrCl5-X:WjDLXzfZdMI9

type="submit" appears only once in the entire file...
value="Continue" appears only once in the entire file...

No other line in the html file has the word submit so it can be a valuable marker...
Value="Continue" is not used anywhere else either..

Thanks for any help....

I will over and over pull out the name to use in DOM with getbyname.. but the DOM will not pick up the name as it changes each time... so I have to use something to get the name every time so I can plug it in to force a click of that Continue button using the long varying name as Identification.... as NO ID is used..


Logged
tommytx
Expert
****
Offline Offline

Posts: 102


View Profile WWW
« Reply #1 on: September 21, 2010, 11:07:43 AM »

One more tidbit... this does not run in php, its running in Autoit... however I believe autoit will run most any of the normal regex code... but there may be a few things php can handle that autoit will not understand....
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10009



View Profile
« Reply #2 on: September 21, 2010, 01:09:57 PM »

Without testing, I believe this is how it could look (one way of doing it) if I implemented it in PHP or JavaScript:

Assuming that the "submit" only appears once in the document, you've got a great anchor.

/submit" name="([^"]{1,256})/i

Essentially, find submit" name=" then collect everything that is not a quote (meaning up till) between 1..256 characters. I'm not sure right ATM but I think you could just go ([^"]*) as well, meaning any number of characters up to a quote.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
tommytx
Expert
****
Offline Offline

Posts: 102


View Profile WWW
« Reply #3 on: September 21, 2010, 01:19:39 PM »

Thanks Perk... I will try this when I get back to my office later tonight.
Logged
DangerMouse
Expert
****
Offline Offline

Posts: 242



View Profile
« Reply #4 on: September 21, 2010, 01:49:17 PM »

Maybe a simpler way would be to load the page in to some form of DOM parser and then pull out the value of the attribute? ...I hate regex so I'm biased though!

DM
Logged
lamontagne
Journeyman
***
Offline Offline

Posts: 89


View Profile
« Reply #5 on: September 21, 2010, 03:22:25 PM »

Maybe a simpler way would be to load the page in to some form of DOM parser and then pull out the value of the attribute? ...I hate regex so I'm biased though!

DM

Ruby + Nokogiri/HPricot = Win ... for small stuff anyway
Logged

"Long time no see. I only pray the caliber of your questions has improved." - Kevin Smith
Bompa
Administrator
Lifer
*****
Online Online

Posts: 566


View Profile
« Reply #6 on: September 21, 2010, 10:26:08 PM »

Code:
type="submit" name="(.*?)"
« Last Edit: September 21, 2010, 10:31:00 PM by Bompa » Logged

Whenever I point my finger, I have three pointing back at me.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10009



View Profile
« Reply #7 on: September 21, 2010, 10:32:46 PM »

Bomps what does the question mark do in that regex?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Online Online

Posts: 566


View Profile
« Reply #8 on: September 21, 2010, 11:00:49 PM »

Bomps what does the question mark do in that regex?

It makes it non-greedy so that it stops at the first "

Without the ?, the .* would match all the way to the last " on the page.


« Last Edit: September 21, 2010, 11:04:56 PM by Bompa » Logged

Whenever I point my finger, I have three pointing back at me.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10009



View Profile
« Reply #9 on: September 21, 2010, 11:17:17 PM »

Thanks mate, cool.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #10 on: September 30, 2010, 12:33:07 PM »

Simpler solution is to use .+ instead of .*

+ isn't greedy
Logged

hai
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #11 on: September 30, 2010, 05:10:47 PM »

err yes it is

+ is to match the previous item 1 time or more and is greedy.

.+ would match any string
.* would match even a blank string
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #12 on: October 14, 2010, 10:55:40 AM »

o rite

forgot

nearly everything is greedy on its own except ??, and noone uses that.
Logged

hai
svakanda
Expert
****
Offline Offline

Posts: 131



View Profile
« Reply #13 on: December 01, 2010, 06:06:08 AM »

your MOM is greedy, vs_loathe!!!!!  Do you want to buy a picture?!@?!?Huh???/ 
 ROFLMAO
Logged

a ship is safe in the harbor, but that's not what it's for.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!