detect samepattern

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fyne

    #1

    detect samepattern

    I have a lot of string data, I want to know if data_i is subtring of
    data_{i+1}
    a simple case, data1=atcgat*ga tta, data2=atcgat*ts gatgat, they both
    separated by an asterisk

    I did


    Regex separator=new Regex(@"^(\**)$ ");
    then Ismatch() to check it

    but this is incorrect, could you help me ? i am very new to C# please
    help me

    Thanks

  • Ebbe Kristensen

    #2
    Re: detect samepattern

    Fyne wrote:
    I have a lot of string data, I want to know if data_i is subtring of
    data_{i+1}
    a simple case, data1=atcgat*ga tta, data2=atcgat*ts gatgat, they both
    separated by an asterisk
    >
    I did
    >
    >
    Regex separator=new Regex(@"^(\**)$ ");
    That regex matches a line containing zero or more asterisks

    Something like this

    Regex separator=new Regex(@"^.*\*.* $");

    will match an optional substring, one asterisk and another optional
    substring, i.e. any string containing an asterisk. However, if the string
    contains more than one asterisk, it will (probably) match on the last
    asterisk.

    You can tighten this up a bit:

    Regex separator=new Regex(@"^[^\*]*\*[^\*]*$");

    This will match a string that contains exactly one asterisk, optionally
    surrounded by non-asterisk characters.
    but this is incorrect, could you help me ? i am very new to C#
    Hmm, I think it's more like you're new to regular expressions. Take a look
    at Regex Coach at http://weitz.de/regex-coach/

    Ebbe


    Comment

    Working...