Search code examples
javascriptregexstringfunctionstring-parsing

String function task in javascript


Hi guys I'm trying to take a URL of the form

http://www.domainname.com/stuff/morestuff/content?extrastuff

And using a JavaScript string function parse out "content" based on the surrounding regular expressions "morestuff/" and "?". Any help would be greatly appreciated.


Solution

  • var c = yourString.match(/\/morestuff\/([^?]*)/)[1];