LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-14-2014, 10:01 AM   #1
Onion master
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Rep: Reputation: Disabled
How to get output of URL (RegExp) A.K.A Regular Expression


So i have found a set of regular expression i can use to grab all data, how do i make it output into .txt files in the server or into some other way so i can lookup the data.

Here is how my URL (RegExp) looks like: /(([A-Za-z]{3,9})://)?([-;:&=\+\$,\w]+@{1})?(([-A-Za-z0-9]+\.)+[A-Za-z]{2,3})(:\d+)?((/[-\+~%/\.\w]+)?/?([&?][-\+=&;%@\.\w]+)?(#[\w]+)?)?/g

How do i output this into either .txt* files names after each PC who uses it or into a server?

Thanks.
 
Old 04-14-2014, 10:17 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
not really following but to redirect any output to a file you use for e.g.:
Code:
ls -l > overwrite-file.txt
ls -l >> append-file.txt
 
Old 04-14-2014, 10:24 AM   #3
Onion master
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks so i add that to the end of my RegExp and make it look like this: /(([A-Za-z]{3,9})://)?([-;:&=\+\$,\w]+@{1})?(([-A-Za-z0-9]+\.)+[A-Za-z]{2,3})(:\d+)?((/[-\+~%/\.\w]+)?/?([&?][-\+=&;%@\.\w]+)?(#[\w]+)?)?/g/ls -l > overwrite-file.txt
ls -l >> append-file.txt

Is that correct? i space it with / if i remember correctly.
 
Old 04-14-2014, 10:42 AM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
sorry, still not following. where are you running this regexp ? what are you trying to do ?
 
Old 04-14-2014, 10:46 AM   #5
Onion master
LQ Newbie
 
Registered: Apr 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
The point of this RegExp is to grab all input from browsers and so on from my customers, and i wish for it to output a personanme.txt to each person
So i can grab the data from FTP later on.

Basically every person's data to be outputted into his very own .txt file.
 
Old 04-14-2014, 11:09 AM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
please give a sample input and a sample output and maybe we can provide some advice.
 
Old 04-14-2014, 10:01 PM   #7
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
A regex by itself won't do anything. You need to give it to an program (or application or executable) to apply it to your data. The three most likely programs you might use it with are sed, awk and perl. (grep also uses regexes, but that doesn't look like it's for grep.)

Do you know which one you're using?

Also, the trailing g puzzles me. I've only used it in substitutions, s///g, not matches. But perlop says, "The /g modifier specifies global pattern matching--that is, matching as many times as possible within the string. How it behaves depends on the context. ..."

But are you expecting really long lines with multiple matches per line?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Output of Regular expression sebelk Linux - General 3 09-02-2013 11:01 PM
[SOLVED] Regular expression to match URL matches fragments - Python madsovenielsen Programming 4 08-29-2010 09:44 AM
extract substring using sed and regular expressions (regexp) lindylex Programming 20 12-22-2009 10:41 AM
regular expression sang_froid Linux - General 4 12-09-2009 06:58 PM
Regular expression to match a valid URL string vharishankar Programming 13 07-21-2005 09:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration