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
https://forums.phpfreaks.com/topic/43274-regexhelp/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.