regular expressions - within the brackets

  • Thread starter Thread starter xkeops
  • Start date Start date
X

xkeops

Not sure this is the group I should ask my question. I have this
string: [[_src|_alternate]]
and I would like to have a RegEx pattern to replace it with: <a
href="_src">_alternate<a/> (wiki way)

I know so far to process [[some info]]

<code>
function ParseContent(byval sText as string)
Dim oregexp As New Regex("\[\[([^\]]+)\]\]")
Return oregexp.Replace(sText, "<a>$1</a>")
end function
</code>

ParseContent("This is a [[linq]] for you.") will output
<code>
This is a <a>linq</a> for you.
</code>

Thanks,
xke
 
It looks like this pattern it's doing the job:

Dim oRegExp As New Regex("\[\[([^\]]+)\|([^\]]+)\]\]")
Return oRegExp.Replace(sText, "<a href=""$1"">$2</a>")

Looking forward for your input on this.
 
Hello xkeops,
It looks like this pattern it's doing the job:

Dim oRegExp As New Regex("\[\[([^\]]+)\|([^\]]+)\]\]")
Return oRegExp.Replace(sText, "<a href=""$1"">$2</a>")

Looking forward for your input on this.

I don't think I could have done it better than that. Was that your first
try at regular expressions? If so, you have some talent - most people are
initialy hopelessly confused when they need to match characters that also
have special meaning.


Oliver Sturm
 
Helloxkeops,
Thanks Oliver.


Dim oRegExp As New Regex("\[\[([^\]]+)\|([^\]]+)\]\]")
Return oRegExp.Replace(sText, "<a href=""$1"">$2</a>")
Looking forward for your input on this.

I don't think I could have done it better than that. Was that your first
try at regular expressions? If so, you have some talent - most people are
initialy hopelessly confused when they need to match characters that also
have special meaning.

Oliver Sturm
--http://www.sturmnet.org/blog
 
Back
Top