Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Parse URL, Extract part after .edu/

  •  03-16-2009, 5:18 PM

    Parse URL, Extract part after .edu/

    I'm trying to create two javascript bookmarklets:
    1. Take the current URL of the page and open a new window with a URL
    based on the current page. Some examples (I use "->" to mean "this
    URL turns into that URL"):
    http://example.edu/som/faculty_staff.cfm#HeaderTitle -> https://authoring.example.edu/som/login.cfm
    http://example.edu/som/faculty_staff.cfm -> https://authoring.example.edu/som/login.cfm
    http://example.edu/som/ -> https://authoring.example.edu/som/login.cfm
    http://example.edu/news/webpublishing/index.cfm -> https://authoring.example.edu/news/webpublishing/login.cfm
    2. Take the current URL of the page and open a URL (in the same window) based on the current page.  Some examples:
    http://example.edu/som/faculty_staff.cfm#HeaderTitle -> https://authoring.example.edu/som/faculty_staff.cfm
    http://example.edu/som/faculty_staff.cfm -> https://authoring.example.edu/som/faculty_staff.cfm
    http://example.edu/som/ -> https://authoring.example.edu/som/
    http://example.edu/news/webpublishing/index.cfm -> https://authoring.example.edu/news/webpublishing/index.cfm
    I plan to use these bookmarklets in sequence, first pressing 1 to log into the CMS, then pressing 2 to edit the current page.
    I'm a regex newb. I thought this would be a simple enough problem that I could teach myself some regex and figure it out. But I'm having trouble even getting started. 
    Many thanks in advance for any help! 
    Filed under: , ,
View Complete Thread