How to match "any character" in regular expression?

Saobi picture Saobi · May 26, 2010 · Viewed 872.3k times · Source

The following should be matched:

AAA123
ABCDEFGH123
XXXX123

can I do: ".*123" ?

Answer

Delan Azabani picture Delan Azabani · May 26, 2010

Yes, you can. That should work.

  • . = any char except newline
  • \. = the actual dot character
  • .? = .{0,1} = match any char except newline zero or one times
  • .* = .{0,} = match any char except newline zero or more times
  • .+ = .{1,} = match any char except newline one or more times