Parsing longer strings

  • Thread starter Thread starter Advait Mohan Raut
  • Start date Start date
A

Advait Mohan Raut

Hello friends,
I want to parse a string which has many tokens. Some tokens may be
present or absent.
eg.
A --> B,C,D,E ;

B --> b,M,N | null ;

C --> O,c, (P|Q) ;

....
...
..
E --> T, CR-LF, space;
....
....
....

end

such type of grammar, I want to parse and to read necessory tokens.
But no production rule is recursive or mutual recursive.
Is it worth to use Regex or Regex with named capturing?
If it is enough, then can someone point to some good tutorial for
regex with *named capturing* ?

Yours
Advait
 
Hello friends,
In the above post, by the word 'longer stirings', I meant to say
size < 1k

yours
Advait
 
Advait Mohan Raut said:
Hello friends,
I want to parse a string which has many tokens. Some tokens may be
present or absent.
eg.
A --> B,C,D,E ;

B --> b,M,N | null ;

C --> O,c, (P|Q) ;

....
...
..
E --> T, CR-LF, space;
....
....
....

end

such type of grammar, I want to parse and to read necessory tokens.
But no production rule is recursive or mutual recursive.
Is it worth to use Regex or Regex with named capturing?
If it is enough, then can someone point to some good tutorial for
regex with *named capturing* ?

Yours
Advait

I'm not sure I understand why standard string.Split() would not work. You
just need to be aware you will have null items where there are consecutive
tokens, such as in item C between the comma and open parenthesis. I may be
misunderstanding your context however, and (P|Q) is in your mind one value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top