문제

Can Anyone help me understand what the below pattern means:

/^([a-zA-Z0-9]){1}([a-zA-Z0-9\-\._]){0,27}\.([a-zA-Z]){1}([a-zA-Z0-9]){1,3}/

What a string must have so that it bounds to the above pattern.

These preg_match patterns are so confusing to understand. ! We are using it to see that a filename conforms to above pattern.

Regards, Sagar

도움이 되었습니까?

해결책

Basically, you are matching filenames that start with a letter or digit, followed by the characters letter, digit, -, ., _, any number of times up to 27, even 0 times. Then, there is a ., probably separating the extension, which is composed of a letter followed by the characters letter, digit any number of times from 1 to 3.

Some examples:

a.aa, 0_.A0a, A---____-_.a999

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top