Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expressions

Status
Not open for further replies.

REALTIME

Programmer
Mar 13, 2000
1
US
Hi,
Can someone please tell me how to embed regular expression in
scanf, sscanf or fscanf. My guess is that it may be the same for all these io functions.

Thanks
 
You can't.
There is only one thing which even comes close, and that is a scan set (or it's complement).
Eg.
[tt]scanf( "%[0-9]", myNumStr );[/tt]
Which in regex terms is [tt][0-9]+[/tt]

If you want anything more complicated than that, then the best thing to do is read a line using fgets(), then use one of the standard regex packages and parse the line yourself.


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top