Sunday, 15 May 2011

Search for Specific raw input python -


So im trying to check my script to ensure that the user input is in a correct format. For, I'm trying to input the user such string that looks:

0 B / 4B / 07

I have to make sure that the script knows that the string Should look exactly like with different numbers and letters, but on total 8 I have a lane, and / she is in exactly the same situation I know that there should be a way to do this again with the module, but I can not understand it. any suggestion?

import def check (word): pattern = "^ [0- 9a-z ] {2,2} / [0- 9a-z] {2,2} / [0- 9a-za] {2,2} $ "m = ri. Search (pattern, word) if M: print ("true") and: print ("wrong") ########################## ## & gt; You can use regex for this

(/ 0 B / 4B / 07 ') O / P true & gt; ('0 B / 4B / 075')>

or if len (x) == 8 and x [2] == '//' and x [5] == '//' A few things like this: Tim Castelligins


No comments:

Post a Comment