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

Regular expressions in Lua

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Pattern

You can also use character classes in pattern strings. A character class refers to a pattern item that can match any character in a particular character collection. For example, the character class% d matches any number. So you can search for a date in dd/mm/yyyy format using the pattern string'% d% d _ Rank% d% d':

S = "Deadline is 30 Compact 05Compact 1999, firm"

Date = "% d%d/%d%d/%d%d%d%d"

Print (string.sub (s, string.find (s, date)-- > 30 Universe 05 Universe 1999

The following table lists all the character classes supported by Lua:

. Arbitrary character

% a letter

% c control character

% d number

L lowercase letters

% p punctuation character

% s blank character

% u capital letters

% w letters and numbers

% x hexadecimal number

Z represents the character of 0

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

Internet Technology

Wechat

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

12
Report