MitsuStyle

MitsuStyle (http://www.mitsustyle.com/forums/index.php)
-   The Parking Lot - On & Off Topic (http://www.mitsustyle.com/forums/forumdisplay.php?f=21)
-   -   Computer haaaaalps (http://www.mitsustyle.com/forums/showthread.php?t=35441)

tehehodi 12-09-2015 09:36 AM

Computer haaaaalps
 
I need some help with the beep booping. I figured I can probably reach more nerds on here than my facebook. Maybe we can use this thread as a "I got a BSOD on such and such device because I watch too many adult films online" type of thread. Anyway, here we go...

JAVASCRIPT/REGEX NERDS! I need help with executing a regexp using the exec() method. I get an SyntaxError: invalid regexp group.
<script>
function regPatExample(){
//The address I'm trying to sift through: file:///C:/Users/test/Documents/School/Web%20Design%20and%20Implementatin/Assignments/result.html?firstname=testies&lastname=mctesticles
var address = window.location;
var regFirstName = /(?<==)(.*)(?=&)/;
var regLastName = /(?<=lastname=)(.*)/;
document.getElementById("firstname").value = regFirstName.exec(address);
document.getElementById("lastname").value = regLastName.exec(address);
}
</script>

When I put the address into my text editor(sublime text), I am able to use the regexp and it matches correctly.

tehehodi 12-09-2015 03:06 PM

Re: Computer haaaaalps
 
Apparently, Javascript doesn't support positive lookbehind. So this was devised with some help:

regFirstName = /(?==(.+)&)/;
regLastName = /(?=lastname=(.+))/;

but now I'm getting a comma such as ",testies" and ",mctesticles"

polishmafia 12-09-2015 03:47 PM

Re: Computer haaaaalps
 
What does the data look like in your file? How is it formatted?

turbotalon1g 12-09-2015 05:05 PM

Re: Computer haaaaalps
 
I wanna make 100k. Tags few on this thread

tehehodi 12-09-2015 05:54 PM

Re: Computer haaaaalps
 
Quote:

Originally Posted by polishmafia (Post 459390)
What does the data look like in your file? How is it formatted?

It's suppose to search that "string" which is a URL that is commented out, nested inside of the script tags.

address = "file:///C:/Users/test/Documents/School/Web%20Design%20and%20Implementatin/Assignments/result.html?firstname=testies&lastname=mctesticles ";

polishmafia 12-09-2015 11:01 PM

Re: Computer haaaaalps
 
Right. I need to see a sample of the file it is supposed to parse.

I think the code is good, but it may be the file layout.

tehehodi 12-10-2015 07:24 AM

Re: Computer haaaaalps
 
It's not actually searching a file though. So I don't know what you mean? It's searching that specific string. Not the file. The file is the path to a results page of a query. The query submits as a GET method(which yes, isn't safe) but it's part of an exercise. It's suppose to grab the first name value and last name value and put those in a read only text box on a results page. Sorry if I didn't word all that correctly.

Regexp regardless of format should pick it out assuming the pattern is correct. At least, that's my understanding.

A//// Guy 12-10-2015 08:41 AM

Re: Computer haaaaalps
 
https://memecrunch.com/meme/2DCZS/tp...jpg?w=1024&c=1


All times are GMT -5. The time now is 12:32 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.