php - Tokenize string and know which part of delimiter grabbed -


I want to tokenize the functioning of PHP with a strtok () and it Want to know that the part of the delimiter caught the current token?

So here's an example:

  Some of my comments: one, two, three   

if I use now :

  $ token = strtok ($ string, '#:,'. PHP_EOL);   

I get my comment as the first code because # and new line it was token Was there. So what is the probability of getting the starting and interval of the current token now?

If you're looking for a way to include the delimiter again because they have something The special syntax is - you should use syntax tools to not separate your delimiter because it is not intended for this function.

Instead you can try to use it:

  $ string = '#my comment something: one, two three'; // Note that & lt ;? Php is required to parse the PHP syntax: $ result = token_get_all ('& lt ;? php'. $ String);   

- This will parse the syntax and dividing lexam into the resulting array (so that you will get your comments and your strings with array members, which are : , < code>, E TC).

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -