0

hi . can someone plz explain how to do regex in C.
input: a text file.
aim: read each line from the text & check if a RegEx pattern exists. finally return that pattern if it exists.

plz share any algo or code snippets if u have.thx.

4
Contributors
6
Replies
10
Views
8 Years
Discussion Span
Last Post by rubberman
0

1. Start from http://en.wikipedia.org/wiki/Regular_expression
2. Select, download and install one of C regex libraries.
3. Get the library manual, read it carefully and see examples in the distributive...

hi ArkM. am using PCRE C API.
but am getting error when i pass a pattern as a parameter. can u help?
pattern is "/\d\d/"
error : unknown escape sequence '\d'

thx

0

If you want to place \d in C string literal, write \\ twise. Didn't you know that backslash is a special escape character in C?

0

aim: read each line from the text & check if a RegEx pattern exists. finally return that pattern if it exists.

There is exactly this example, just reading from stdin instead of custom file, at http://mij.oltrelinux.com/devel/unixprg/#regex . There's also a quick reference on the RegEx syntax on there.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.