names_pattern() use

Hello people !
I am new to R and learning it.
I am trying to learn the names_pattern () function wherein a blog blogger has used a code in the "who" dataset that I am unable to understand.

who %>% pivot_longer(
cols = new_sp_m014:newrel_f65,
names_to = c("diagnosis", "gender", "age"),
names_pattern = "new_?(.)_(.)(.)",
values_to = "count"
)

Can anyone please explain how he used this - names_pattern = "new_?(.)_(.)(.)" and also how to use this syntax.
Provide any link to a blog or video wherein I can learn from.

Thank you!

The syntax is that of a domain specific language (string processing) called REGEX.
You can read about it/its history on wikipedia.
There are many tutorials and online lewsons, that are searchable , look for regex.

Here is one.

Thank you!
Means a lot

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.