Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Various cases of regular expressions

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Find a blank line: ^ [\ t] * $\ r\ n

Find the 8-digit hexadecimal number in which the last digit is a lowercase letter: 0x [0-9] {7pr é 7} [amerz] {1mer 1}

Look for an 8-digit hexadecimal number with at least one lowercase letter: 0x (? = [0-9] {0prit 7} [a Murz]) [a-z0-9] {8jue 8}

Intercept all characters before the first parenthesis of the current line: (? = ^ [^ (| ^\ r | ^\ n] * [(| (]) ^ [^ () *)

Import re# looks for 8-digit hexadecimal numbers with at least one lowercase letter And modify it to uppercase def hex_to_upper (hexStr): listHex = re.findall ("0x (? = [0-9] {0je 7} [a Murz]) [a-z0-9] {8jue 8}", hexStr) print listHex newStr = re.sub (r "0x (? = [0-9] {0cr 7} [a murz]) [a-z0-9] {8pm 8}", "0XLLLLLLLL", hexStr) for obj in listHex: '-', obj [2:] newStr = re.sub (r "0XLLLLLLLL",'0x main__': + obj [2:] .upper (), newStr, 1) return newStrif _ _ name__ = ='_ main__': a = "oei0x7822CDE2lwnfnsodf0x7822abe2lsdksdf1023900x98de293c988e9we0x98112931ii" print a print hex_to_upper (a)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report