in reply to searching for a string w/ a * in any single position?

Tell us about the bigger problem. Not your solution, but the problem it solves. For example, could it be that you are trying to search for a word that may be misspelled?

Note that your *{1} syntax is not (Perl) regular expression syntax so it's not clear if you mean 'match any single character' or something else. Rather than an invented (or non-Perl regex) syntax, you should either use a correct Perl regex syntax or a sample of matching and mismatching strings (both would be even better).


Perl is environmentally friendly - it saves trees
  • Comment on Re: searching for a string w/ a * in any single position?

Replies are listed 'Best First'.
Re^2: searching for a string w/ a * in any single position?
by mdunnbass (Monk) on Oct 09, 2007 at 16:23 UTC
    The bigger problem... I have a program that allows users to search text files in FASTA format for an arbitrary number of strings of arbitrary length (motifs of DNA nucleotides to be specific). These strings are typically 6-15 characters long.

    I have it currently set up to perform the searches with m//g an so on, where I have converted the user input strings into a regexp, based on whether they input only A,C,G, or T, or whether they used standard degeneracies, which allow things like specifying 'R' to mean either 'A' or 'G', etc. So, if the user inputs 'ART', the search string is actually "A[R|A|G]T", and so on. In this context, specifying 'N' at any point is equivalent to [A|C|G|T|N].

    What I am looking to do now, is search for whatever user input string, where, in the 5/6 case of my initial example, any 1 character can match N, but the rest of the string must match exactly. Additionally, I am looking to make this an optional feature, not a given of every search, and I want to make the number of N adjustable.

    I hope that clarifies things a bit...

    Thanks
    Matt

        Thanks for the link, but from what I can tell, I have already independently coded everything found on that page....

        Based on the other replies to my OP, it looks like the better thing to do for me would be to find a way to compare the Hemming distance of $string to subsets of the overall sequence, each of the same length as string.

        Whether or not I can implement that in the context of the program I've already devised, without a major overhaul is the main question. So, in the meantime, I'll be reading up and playing around withit.

        Thanks to all who answered though,
        Matt