BartlebyScrivener wrote:
> Even without the marker, can't you do:
>
> sentence = "the fabric is red"
> colors = ["red", "white", "blue"]
>
> for color in colors:
> if (sentence.find(color) > 0):
> print color, sentence.find(color)
>
That depends on whether you're only looking for who
Even without the marker, can't you do:
sentence = "the fabric is red"
colors = ["red", "white", "blue"]
for color in colors:
if (sentence.find(color) > 0):
print color, sentence.find(color)
--
http://mail.python.org/mailman/listinfo/python-list
Taking you literally, I'm not sure you need regex. If you know or can
find position n, then can't you just:
sentence = "the color is $red"
patterns = ["blue","red","yellow"]
pos = sentence.find("$")
for x in patterns:
if x==sentence[pos+1:]:
print x, pos+1
But maybe I'm oversimplifyin
On Mon, 12 Dec 2005 [EMAIL PROTECTED] wrote:
> I'd need to perform simple pattern matching within a string using a list
> of possible patterns. For example, I want to know if the substring
> starting at position n matches any of the string I have a list, as
> below:
>
> sentence = "the color is
[EMAIL PROTECTED] wrote:
> Hi,
>
> I'd need to perform simple pattern matching within a string using a
> list of possible patterns. For example, I want to know if the substring
> starting at position n matches any of the string I have a list, as
> below:
>
> sentence = "the color is $red"
> patte