Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Regexp - string is not followed by character and does not...

I have this line:

return "[a-z]$scheme*:/{2}(?:(?:[a-z0-9\-._~!$&'($inline*+,;=:mad:|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:mad:|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:mad:/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:mad:/?|]+|%[\dA-F]{2})*)?";



It's got regexp in it for defining a url.


What I need to do is add something in there for:

--- and is not followed by "["


http://www.hbgames.org <---- this should be fine (followed by no characters)
http://www.hbgames.org <---- this should be fine too (followed by a space)
http://www.hbgames.org[ <---- this should not
http://www.hbgames.org[/img] <---- this should not either


I really don't have a clue what I'm doing here and am hoping this is possible.

Anyone have any ideas?



Hopefully you can see the problem above. The code is generating the automatic hyperlink from the url. I want it to not do that for anything followed by [, as I have something special planned for that.
 

e

Sponsor

that is the worst, longest regexp i have ever seen. A proper URL matcher is usually much shorter than this. Do you really need to use that one?

EDIT:

Ok, so you'd take the current regexp, but add at the end: (?!\[)

I think that'd do it, but then again I have no idea what operation you're applying on the regexp.

Basically, you'll want to use negative look ahead on your expression. http://www.regular-expressions.info/lookaround.html
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top