regular expressions - within the brackets

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xkeops@gmail.com

    #1

    regular expressions - within the brackets

    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">_al ternate<a/(wiki way)

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

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

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

    Thanks,
    xke

  • xkeops@gmail.com

    #2
    Re: regular expressions - within the brackets

    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.




    On Feb 5, 2:56 pm, xke...@gmail.co m wrote:
    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">_al ternate<a/(wiki way)
    >
    I know so far to process [[some info]]
    >
    <code>
    function ParseContent(by val sText as string)
    Dim oregexp As New Regex("\[\[([^\]]+)\]\]")
    Return oregexp.Replace (sText, "<a>$1</a>")
    end function
    </code>
    >
    ParseContent("T his is a [[linq]] for you.") will output
    <code>
    This is a <a>linq</afor you.
    </code>
    >
    Thanks,
    xke

    Comment

    • Oliver Sturm

      #3
      Re: regular expressions - within the brackets

      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
      --
      Software Architecture and Development, Functional Programming and Random Musings

      Comment

      • xke

        #4
        Re: regular expressions - within the brackets

        On Feb 12, 3:17 pm, "Oliver Sturm" <oli...@sturmne t.orgwrote:
        Helloxkeops,
        >
        It looks like this pattern it's doing the job:
        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.or g/blog

        Comment

        Working...