-2

What does this regular expression stand for (.*)@(.*). I came to know that (.*) matches any character with period any number of times.

But I couldn't understand the meaning properly. Also, what does two of them separated by @ mean?

Hong Ooi
  • 51,703
  • 12
  • 121
  • 162

2 Answers2

1

.*@.* matches any string containing the @ character Example of strings that this pattern would match

  • @
  • @qe
  • asrrd@
  • qw3e@as112d

(.*)@(.*) would just return whatever is before and after the @ character

Example:

  • for @ would return two empty strings '' , ''
  • for @qe rule will return '' and 'qe'
  • for asrrd@ would return 'asrrd' and ''
  • for qw3e@as112d would return 'qw3e' and 'as112d'
Andrea Corbellini
  • 15,400
  • 2
  • 45
  • 63
0

(.*)@(.*) can match any of the following:

@, .@., ..@., jbkbhjh...@...njbh ...

* means one or many characters.

so this regex means a @ symbol enclosed by any number of chars

Also, what does two of them separated by @ mean

Answer to this is: the @ symbol is required for a text to match this regex

mrid
  • 5,408
  • 5
  • 19
  • 56