Skip to main content
Code Review

Return to Question

Copy edited. Moved meta information to the end (perhaps it should be moved comments?). Used the official name of Stack Overflow - see section "Proper Use of the Stack Exchange Name" in http://stackoverflow.com/legal/trademark-guidance (the last section).
Source Link

Javascript http regex JavaScript HTTP regular expression

I asked this on Stackoverflow, however I was informed that the type of question was not really fit for there, which I understand.

I am currently using the following to convert [url=][/url] to a htmlan HTML link:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")

That work's fine.

I then added on another replace function using a regexregular expression to replace www with http://www like so:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")
.replace(/www/g, "http://www");

This is probably not the best/efficient method and also does not support https:// which is not a priority at the moment, but it is something I would like to include at some point. Could someone please advise me on what IWhat could I do to improve the regexregular expression?

I asked this on Stack Overflow. However, I was informed that the type of question was not really fit for there, which I understand.

Javascript http regex

I asked this on Stackoverflow, however I was informed that the type of question was not really fit for there, which I understand.

I am currently using the following to convert [url=][/url] to a html link:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")

That work's fine.

I then added on another replace function using a regex to replace www with http://www like so:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")
.replace(/www/g, "http://www");

This is probably not the best/efficient method and also does not support https:// which is not a priority at the moment but is something I would like to include at some point. Could someone please advise me on what I could do to improve the regex?

JavaScript HTTP regular expression

I am currently using the following to convert [url=][/url] to an HTML link:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")

That work's fine.

I then added on another replace function using a regular expression to replace www with http://www like so:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")
.replace(/www/g, "http://www");

This is probably not the best/efficient method and also does not support https:// which is not a priority at the moment, but it is something I would like to include at some point. What could I do to improve the regular expression?

I asked this on Stack Overflow. However, I was informed that the type of question was not really fit for there, which I understand.

Tweeted twitter.com/#!/StackCodeReview/status/383294155444985856
Source Link
Lodder
  • 145
  • 6

Javascript http regex

I asked this on Stackoverflow, however I was informed that the type of question was not really fit for there, which I understand.

I am currently using the following to convert [url=][/url] to a html link:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")

That work's fine.

I then added on another replace function using a regex to replace www with http://www like so:

s = message.replace(/\[url=([^\]]+)\]\s*(.*?)\s*\[\/url\]/gi, "<a href='1ドル'>2ドル</a>")
.replace(/www/g, "http://www");

This is probably not the best/efficient method and also does not support https:// which is not a priority at the moment but is something I would like to include at some point. Could someone please advise me on what I could do to improve the regex?

default

AltStyle によって変換されたページ (->オリジナル) /