Jump to content

regex+help


Aretai

Recommended Posts

Hi,

 

I've a problem with regex and PHP. I'm trying to link to a files stored on my server (Solaris) with grep command:

 

grep -irU $input /opt/users/aretai

 

$input is the text that is being searched by the user. Then it's just simple grep command (recursive and binary files are matched).

 

While this command is being run on my server it produces the list like this:

 

Binary file /opt/users/aretai/projects/test/test.doc matches

Binary file /opt/users/aretai/projects/fun/games.xls matches

Binary file /opt/users/aretai/projects/home_tools/tools.doc matches

etc

/opt/users/aretai/projects/test.txt:search

last line is for the file created with vi under linux 'search' is the string that was being searched this time.

 

I want to create a link to a given file and then pull it on the website:

the output of the command is stored in the variable $output:

$output = 'grep -irU $input /opt/users/aretai';

 

I want to replace the text "Binary file /opt/users/aretai/projects" and "/opt/users/aretai/projects/" with a <link> tag and " matches" or :$input with a </link> tag then it will be displayed as a link on my page.

 

So far I've achieved that I get a list of the files, but there is a little bit more

I get a link of the whole output instead of a single line. :P

 

thx for answers, ;D

Aretai

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.