1. Match for a single space - eg " "
2. Match for a Forward Slash(/) OR (|) Question Mark (\?)
3. Match for an alpha character followed by a alpha numeric character.
I am trying to enable all the different types of urls to be clickable links, including the urls wrapped in text. Got this following expression that confused me, and when testing it does break as well. I am trying to fully understand it before modify.
1. why the alpha is inside double square bracket [[:alpha:]],instead just one [:alpha:], is it trying to make a balance with the :space: and :alnum:, but no other meannings?
2. [^<>[:space:]]+ matches for not(^) a left arrow(<) or right arrow(>) or a single space[:space:], not one or more of them should appear at that position at all. am i right?
3. the backreference refers to the match inside the round bracket, not square bracket, is it?
4. even if backreference can count with square brackets, it starts from 1, not 0, what does the 0 refer to here?
hunt, Are you trying to make it so that whenever someone types in a website address and submits it, it automatically gets changed to a hyperlink? Like a forum?
1. [:alpha:] and [:alphanum:] are called "Special Range 'metacharacters'". Treat them as a constant. The rule is that they MUST be place inside another set of brackets to give the programmer more options. eg. [[:alpha:]a-d] will search for any alpha character from a through to d.
2. Correct. The ^ symbol is called circumflex. This statement means that matches in this position should be anything BUT a space, a less than or more than symbol. I imagine the reason for this is so the statement will ignore tags in HTML. eg. <a href="....
3 and 4 - Not sure what you mean by "backreference" sorry.
You can find a ton of info on this by searching for "regular expressions", it's the same across most languages.
2. a string of text which has been embedded in html tag, which is clickable text that copy and paste from somewhere else.
When reading the backreference, since it uses 1,2,3 ..to count. I am confused of the rule of counting it. Thought only count those in square brackets, and starting count number is 1.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.