A
A
Andrey Frolov2015-11-01 21:37:03
PHP
Andrey Frolov, 2015-11-01 21:37:03

How to find out how many spaces or tabs before the beginning of letters/characters in a string?

that is, the lines "\t\t\tText blah blah"
how to find out what exactly 3 tabs are at the beginning of this line?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2015-11-01
@Taraflex

Cut out the regular expression and count.
^\t+

A
Alexey, 2015-11-02
@AlekseyChuyan

Look towards substr_count(), which will return the number of occurrences of a substring in a string. And there you will calculate the sum of tabs + spaces or whatever else you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question