PDA

View Full Version : Detect specific patterns in C



vikkyhacks
July 21st, 2012, 10:16 PM
I have this huge problem.

char *a="asdasd75erbfv87xxcvbintasfloat87xzjhbxcvdouble"

how do i search and display specific patterns( float int double (in bold)) from that string a. ????

MadCow108
July 21st, 2012, 10:18 PM
regular expressions are often a good way to find patterns in text:
http://en.wikipedia.org/wiki/Regular_expression
http://www.gnu.org/software/libc/manual/html_node/Regular-Expressions.html

though if your pattern is so specific you may be better of just using strstr

Bachstelze
July 21st, 2012, 10:24 PM
C is not the right language to do text-related stuff.

vikkyhacks
July 22nd, 2012, 06:39 AM
Thanks fr t reply bt i need to get my prgm wrking in both linux and turbo c++, that regexp header is not available in Turbo c++

lisati
July 22nd, 2012, 07:00 AM
It might be an idea to start with something like the previously mentioned strstr (http://www.codecogs.com/reference/computing/c/string.h/strstr.php).

Which language are you primarily using, C or C++?

codemaniac
July 22nd, 2012, 07:41 AM
As mentioned by Bachstelze , C might not be the best choice to do text manipulation .

By combining several small, but powerful, text processing tools through UNIX pipes, text can be transformed and manipulated in a myriad of ways and can save you hundreds of lines of C code .