Author Topic: [Java] Looking for some regex help (greasemonkey script)  (Read 3939 times)

0 Members and 1 Guest are viewing this topic.

Offline LordVader

  • Full Member
  • ***
  • Posts: 113
  • Knowledge is power.
    • View Profile
    • James Moss on the web!
[Java] Looking for some regex help (greasemonkey script)
« on: January 31, 2010, 05:18:25 pm »
Working on a script for facebook and im try'n to catch url's that get hashes appended to them and redirect the page to the proper url without the hash..
for example:
http://www.facebook.com/<username>?v=app_2392950137&ref=profile#/reqs.php

I would like to redirect back to:
http://www.facebook.com/reqs.php

The problem is there is a wide variety of possible urls in many combinations i've tried some of the url cleaner script exampe code and the regex catches most but not all the above example is not caught in this reqex:
Code: [Select]
var reg = /^(http?:\/\/([-a-z0-9]+\.)*facebook\.com)\/[^#]+#(\/.+)/i;
var ugly = reg.test(window.location.href);

Offline LordVader

  • Full Member
  • ***
  • Posts: 113
  • Knowledge is power.
    • View Profile
    • James Moss on the web!
Re: [Java] Looking for some regex help (greasemonkey script)
« Reply #1 on: January 31, 2010, 05:47:13 pm »
Got it solved, the reqex does work, just needed to adjust how I was using it used this as an example it works pretty good actually:
http://userscripts.org/scripts/review/29910

And this is what I needed it for:
http://userscripts.org/scripts/review/57047

If anyone has any suggestions for the above script feel free :)
« Last Edit: January 31, 2010, 06:02:32 pm by LordVader »