![]() |
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. |
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" |
Re: Computer haaaaalps
What does the data look like in your file? How is it formatted?
|
Re: Computer haaaaalps
I wanna make 100k. Tags few on this thread
|
Re: Computer haaaaalps
Quote:
address = "file:///C:/Users/test/Documents/School/Web%20Design%20and%20Implementatin/Assignments/result.html?firstname=testies&lastname=mctesticles "; |
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. |
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. |
Re: Computer haaaaalps
|
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.