Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8039671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:38:49+00:00 2026-06-05T03:38:49+00:00

I want to parse the result of a grep command in a browser. Something

  • 0

I want to parse the result of a grep command in a browser.
Something like grep -nriI "hello" myFolder
The result is a multiline string:

/home/user/folder/file1:1:hello world
/home/user/folder/file2:1:world hello
/home/user/folder/folder/file3:1:bonjour=hello

First I split the lines to have an array. And parse it with this regex: /^(.*?)\:(\d*)\:(.*?)$/

I have some problems.

  1. Parse will not work for result with funny char like double point (:)
  2. When I grep a file, I do not get pah:line number:content but only line number:content so it make the regex more complicated (there is no named group in javascript regex).

Has someone already a good parser or a project which parse it. It has to work in a browser…

I will make a jsfiddle.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:38:51+00:00Added an answer on June 5, 2026 at 3:38 am

    My grep (on Ubuntu Linux) has some options that could help, though neither of them are POSIX standard.

    For ambiguous output:

       -Z, --null
              Output  a  zero  byte  (the ASCII NUL character) instead of the character
              that normally follows a file name.  For example, grep -lZ outputs a  zero
              byte  after  each  file  name  instead of the usual newline.  This option
              makes the  output  unambiguous,  even  in  the  presence  of  file  names
              containing  unusual  characters  like  newlines.  This option can be used
              with commands like find -print0, perl  -0,  sort  -z,  and  xargs  -0  to
              process arbitrary file names, even those that contain newline characters.
    

    For the missing filename:

       -H, --with-filename
              Print the file name for each match.  This is the default  when  there  is
              more than one file to search.
    

    So use grep -nriIHZ and update your regex to something like this (untested):

    /^(.*)\0(\d+):(.*)$/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to parse a JSON string in JavaScript. The response is something like
I want to parse this string hello>kok>peoplekok I want the delimiter to be not
I want to parse a filter string similar to the following: ((Field1 = 'red')
I want to parse the input string and extract the values from it. My
Original I want to parse a string of html code and add newlines after
I want to parse the result of a specific URL using Simple Ajax for
I want to parse and page that takes POST parameters. like this is my
For following HTML, I want to parse it and get following result using Nokogiri.
I want to parse a logfile which has 3 entries. It looks like this:
I want to parse JSON string to some my custom object in Action script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.