rikki Posted October 27, 2014 Author Report Posted October 27, 2014 @thewalterwhite - thanks i tested in that with different combos seems to work fine @walcommon - comma separated values @scrooge - what is re mate? external assembly? @karna - i will check this bro
k2s Posted October 27, 2014 Report Posted October 27, 2014 >>> import re >>> a = 'aaa,bbb' >>> a_regex = re.compile(r'(a{3}),(b{3})') >>> if (re.match(a_regex,a)): print True else: print False True >>> @thewalterwhite - thanks i tested in that with different combos seems to work fine @walcommon - comma separated values @scrooge - what is re mate? external assembly? @karna - i will check this bro its a pythonic approach. "import re" anna kada....antey... importing regular expression (re) module into python namespace and using couple of attributes/methods likes re.compile & re.match if you are looking for just regex expression, highlighted it. want to learn more about regex... here you go. https://docs.python.org/2/library/re.html and want to test your regex against a certain strings , here you go http://www.regexr.com/
k2s Posted October 27, 2014 Report Posted October 27, 2014 @posiedon - what is {3} bro? {m} Specifies that exactly m copies of the previous RE should be matched; fewer matches cause the entire RE not to match. For example, a{6} will match exactly six 'a' characters, but not five.
puli_keka Posted October 27, 2014 Report Posted October 27, 2014 @posiedon - what is {3} bro? IT expects exactly 3 characters. You can set range like {2,4} matches 2 3 or 4 characters \S is any character except space
rikki Posted October 27, 2014 Author Report Posted October 27, 2014 @scrooge ma white dora ni python ante lagaan kattu antademo bro @posiedon - no restriction on characters can be (a,bbbb)
k2s Posted October 27, 2014 Report Posted October 27, 2014 @scrooge ma white dora ni python ante lagaan kattu antademo bro @posiedon - no restriction on characters can be (a,bbbb) okka sari paina ichina links saduvu man.... sadivi Qs adugu....w/o doing ur HW, dont ask others to spoon feed you then use {m,} Specifies that atleast m copies of the previous RE should be matched; fewer matches cause the entire RE not to match. For example, a{3,} will match atleast three 'a' characters or more, but not two, .
rikki Posted October 27, 2014 Author Report Posted October 27, 2014 @scrooge - cool avu bro i know that {m} after asking the q anukuna coz i typed "aaa,bbb" he is assuming 3 char ani thank you cheers
ChampakDas Posted October 27, 2014 Report Posted October 27, 2014 a.matches("^[,]$") hello, office lo i tried but i didn't get I am checking if a string has a comma in its value string a = "aaa,bbb" how could i check if it has a comma or not i did a.match(/*+[,]+*/) this aint working helpp
Recommended Posts