Hello!

Trying to use regexp in glib but I cannot get it to work. I would like to have a regular expression to describe:
[2003-03-11 13:14:12.111] letters letters.:1234 Hello

I have tryed the following expression in 'regular expression testers' and there this works:
^\[\d{4}\-\d{2}\-\d{2}\s\d{2}\:\d{2}\:\d{2}\.\d{3}\]\s\w*\s*\w*\.+\w*\:\d{4}\sHello

But not with glib's regexp. Why is that?:X

Could it be that you have not escaped backslashes in your string?
I.e. in your code the string should be:

const char regex[] = "^\\[\\d{4}\\-\\d{2}\\-\\d{2}\\s\\d{2}\\:\\d{2}\\:\\d{2}\\.\\d{3}\\]\\s\\w*\\s*\\w*\\.+\\w*\\:\\d{4}\\sHello"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.