Jump to content

Recommended Posts

Posted

@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

Posted

 

>>> 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/

Posted

@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.
Posted

@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
Posted

@scrooge ma white dora ni python ante lagaan kattu antademo bro  

@posiedon - no restriction on characters can be (a,bbbb)

Posted

@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, . 

Posted

@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 

Posted

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 

 

×
×
  • Create New...