x Did you like it? Well, then please consider making a donation :)

Regex Library

Regular expression to match C #include file

^\s*\#include\s+["<]([^">]+)*[">] You then want to look at the first capture group when you get a match. You don't say what language you're using, the factor you mention regcomp() leads me to believe that you're using POSIX regex library in C. If that's right, then you want to use the regexec function and use the nmatch and pmatch parameters to get the first capture group.

Type: match, Date: 7/12/2015 4:16:57 PMAuthor: stackoverflow

How do I replace multiple spaces with a single space?

Replace multiple spaces example

Type: replace, Date: 7/12/2015 4:10:18 PMAuthor: stackoverflow

Validate numbers

If Possible, Don't Use Regex To Validate Numbers. If at all possible, use your language. There may be functions to help you determine if the value contained by a string is a valid number. That being said, if you're accepting a variety of formats (commas, etc.) you may not have a choice.

Type: match, Date: 7/12/2015 4:07:04 PMAuthor: stackoverflow

Get only Arabic digits

Use ([0-9]+) if you need to match more than one digit (only Arabic numbers!). Use (\d+) if you need all digits (all unicode digits).

Type: match, Date: 7/12/2015 4:00:33 PMAuthor: stackoverflow

Remove all non alphanumeric characters from a string except dash & space symbol

Replace this Regex with an empty string + Compiled flag

Type: replace, Date: 7/12/2015 3:52:40 PMAuthor: stackoverflow