2015-11-09 40 views
0

使用正則表達式我需要匹配以數字開頭的屬性,可能包含一個斜槓並且也可能包含一個字母。因爲我是初學者,所以我不知道如何開始。這些屬性是來自數據庫表的數據元素。例如,我想匹配所有這些如下數據:使用正則表達式在Python中匹配一個屬性

54/6 
66A 
75 

回答

1

這正則表達式可以幫助你。 (https://regex101.com/r/sJ8tB6/1

(^[0-9A-Za-z\/]+) 

^ = start with 
0-9 = any number 
A-Z = any letter is uppercase 
a-z = any letter in lowercase 
/= and the slash, but you need to escape this with the backslash \ 
+ = one or more match. 

你可以去這個網站,看看例子。 https://regex101.com/r/sJ8tB6/1

問候。

+0

它的工作原理。完善!謝謝:) – MetalMuzu

+0

很酷!你歡迎你! – wu4m4n