Click to See Complete Forum and Search --> : C programming Question


LinuxFanatic
06-15-2005, 06:31 AM
Hi,

I have a programming project in which I have to write
code in c. Unfortunately, I need a perl style regular
expression format. I want to parse a string and extract
info: the format is kind of markup:

In perl I would have written some-thing like this:

$text = " < MaRk >180,234< / MARK><MARK TYPE=\"2\" COLOR=\"red\">256,
278
</MARK><MARK TYPE=\"3\">
298,
156
</MARK><MARK COLOR=\"#aecf98\">300, 234
</MARK>< maRk COLOR=\"green\" TYPE = \"1\">100,200< /MarK >"
if ($text =~ /^(\s*)<(\s*?)mark(\s*?)>(.*?)<(\s*?)\/(\s*?)mark(\s*?)>/is) {
print("Match found. Options : ..... ");
}

Question is how do I write this in C? Any pointers? (pun intended!)

bwkaz
06-15-2005, 07:34 PM
Well, there is a "Perl-compatible regular expression" library floating around somewhere (libpcre). You might want to look into how to use that.