Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

java - 如何在正则表达式中匹配“任何字符”?(How to match “any character” in regular expression?)

The following should be matched:

(以下应匹配:)

AAA123
ABCDEFGH123
XXXX123

can I do: ".*123" ?

(我可以这样做: ".*123"吗?)

  ask by Saobi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, you can.

(是的你可以。)

That should work.

(那应该工作。)

  • . = any char

    (=任何字符)

  • \. = the actual dot character

    (=实际的点字符)

  • .? = .{0,1} = match any char zero or one times

    (= .{0,1} =匹配任何字符0或1)

  • .* = .{0,} = match any char zero or more times

    (.* = .{0,} =匹配任何字符零次或多次)

  • .+ = .{1,} = match any char one or more times

    (.+ = .{1,} =匹配任何字符一次或多次)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...