Why (.+)can match a string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why (.+)can match a string

I thought a (.+)can only math one or more repeats of a single character but the results is it can match any strings. Isn't . means any character ? And I what is the "1" in (.+)\1 mean? Does it means one or more times repeat of the parrten ??

12th Apr 2017, 9:10 AM
Jonyhy
Jonyhy - avatar
2 Answers
0
. Means any char,+means at least one,so (.+) means one or more charactors,no matter these chars are the same or not. ()means group,\1 means obtaining the first group from the answer groups.
12th Apr 2017, 9:18 AM
dailei
0
I finnally understand that \1 is more like \(partten\)\n in java.
12th Apr 2017, 9:19 AM
Jonyhy
Jonyhy - avatar