0

I'm new to regex. I try to research it.

I am reading following article:

http://www.tutorialspoint.com/java/java_regular_expressions.htm

snippet from article:

^   Matches beginning of line.

and

\A  Beginning of entire string

I don't understand the difference. Can you clarify this ?

gstackoverflow
  • 34,819
  • 98
  • 304
  • 641

2 Answers2

6

Difference is apparent when you use MULTILINE switch where ^ is matched at start of every line but \A is still matched only once at start of very first line.

anubhava
  • 713,503
  • 59
  • 514
  • 593
1
String string = "Something is \n here"

String is the whole thing Line is just "Something is "

A string has a single beginning but it may contain more then on lines, in which case each line has its beginning.

dharr
  • 328
  • 1
  • 11