finding numbers in text files

This is a discussion on finding numbers in text files within the C Programming forums, part of the General Programming Boards category; HI guys, Can anyone tell me how to find and delete numbers from a text file. This is what I ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    2

    finding numbers in text files

    HI guys,

    Can anyone tell me how to find and delete numbers from a text file. This is what I have so far

    Code:
    int main(){
         char c, filename[10]; FILE *fp;
    	 printf("Eneter a filename");
    	 scanf("%s", filename);
    	   if((fp=fopen(filename, "r")) !=NULL)
    	      while ((c=fgetc(fp)) !=EOF)
    			fputc(c, stdout);
    	   else
    		   printf("could not open file ", filename);
    char Regex;
    
    char regMatch[] = " ";//string to search for inside of text file. It is case sensitive.
                if (Regex.IsMatch(filename,regMatch))//If the match is found in allRead
                {
                    printf("found\n");
    
                }
                else
                {
                    printf("not found\n");
                }
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Your use of Regex.IsMatch is incompatible with the code being C. You should check whichever flavor of regex you're using to see what it calls 'digit'.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    For starters doclarify what you mean by Regex.IsMatch?
    RTM on regcomp(), esp. how-to use rm_so and rm_eo.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    And I suppose I should mention, if RegEx comes crashing down around your ears, that there is such a thing as isdigit().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:01 PM
  2. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  3. Reading text files on the internet
    By Mavix in forum C# Programming
    Replies: 8
    Last Post: 06-20-2007, 05:38 AM
  4. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 02:17 PM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21