Log in

View Full Version : Computer haaaaalps


tehehodi
12-09-2015, 09:36 AM
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
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
What does the data look like in your file? How is it formatted?

turbotalon1g
12-09-2015, 05:05 PM
I wanna make 100k. Tags few on this thread

tehehodi
12-09-2015, 05:54 PM
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
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
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
https://memecrunch.com/meme/2DCZS/tps-reports/image.jpg?w=1024&c=1