SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Searching a text file for lines that begin with...

    Can I use JavaScript (or some sort of .NET flavor of C#?) to search each line of a loaded text file and delete characters from the given line? The specific characters I would need to have deleted if found at the beginning of each line are
    Code:
    *+
    (asterisk and plus signs).

    How might I do this?

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I use JavaScript...to search each line of a loaded text file
    You're better off using server-side scripts to do this, and read up on regular expression usage for .net to do what you need.

  3. #3
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would, but at the moment, I lack a server or any means of having such.


    So... Any Java Script solutions for this?

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How are you loading this file?

  5. #5
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stereofrog View Post
    How are you loading this file?
    It's a text file I have on my desktop computer. Each line has the plus and asterisk character(s) beginning in each line that is conditionally produced. Since each of these special lines are conditionally produced, it means that not every line has the character set in them. Since I have many lines (thousands), it would be ridiculously difficult (and time consuming) to go through and pick them all out by hand.

    In other words, I could load it anyway possible just as long as the program or script can delete each line that has those characters.

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so you're after automating a local windows task, this is not something that will be run from the internet? If so, this is definitely possible with javascript, using Windows Scripting Host and FileSystemObject. If you google for both, there are tons of examples.

  7. #7
    SitePoint Wizard Wolf_22's Avatar
    Join Date
    Jul 2005
    Posts
    1,714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Confused...

    If so, this is definitely possible with javascript, using Windows Scripting Host and FileSystemObject.
    ...

    "...The FSO object model is contained in the Scripting type library, which is located in the Scrrun.dll file. Therefore, you must have Scrrun.dll in the appropriate system directory on your Web server to use the FSO object model..."

    (Click Above Quote)

    As for the Windows Scripting Host idea, the 101 idea behind these files is to make a "script-comprised-program" that, when double-clicked, will execute its code, yes? If so, that should be simple enough, but my question concerning this is "Why did you mention that my solution could be achieved via JavaScript is Windows Scripting Host is actually, VBScript?"

    Regardless, you did help me figure out some ways to get my needed results. Looks like I have some reading to do.

  8. #8
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FSO is pretty much standard stuff, if I'm not mistaken, scrrun.dll is there in all windows from 98.

    WSH is not language, it's an API. You can write WSH programs in php, if you want.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •