Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-06-2012, 02:51 PM   #1
RazorSharpe
Confirmed User
 
RazorSharpe's Avatar
 
Industry Role:
Join Date: Aug 2001
Location: Scotland
Posts: 2,238
Help with regular expression

Hi,

I have a tab delimited file that is a few thousand lines long and it's gotten messed up. I was hoping someone could provide me a regex command that could help me resolve the issue.

The file contains the following:

title|description|url|site|keywords

the first 500 entries are fine but about 4000 of the rest are mucked up. Instead of taking the form as above, they now look like this

"title
"|description|url|site|keywords

I basically want to preserve the title as is and remove the "\n"

Anyone have any ideas? Would save me a ton of time!

Cheers
__________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
RazorSharpe is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-06-2012, 03:10 PM   #2
Confined
Registered User
 
Industry Role:
Join Date: Jan 2006
Posts: 93
PHP Code:
$preg '@';
          
$preg .= '([a-zA-Z0-9 \!\&\.\/\'\"\#\&\;\_\-\:]+)'//title
          
$preg .= '[\s\r\n\f]*'//newline u want to avoid
          
$preg .= '\|([A-Za-z0-9 \?\/#\;\,\.\:\&\!\'\"]*)'//descr 
          
          
$preg .= '\|([a-zA-Z0-9 \?\,\&\.\/\_\-\:=]+)'//siteurl 
          
$preg .= '\|([A-Za-z0-9 \/\,\.\:\&\;\!\'\"]*)'//tags
          
$preg .= '[\s\t\r\n\f]+'//endofline
          
$preg .= '@i'
as a start. itll be different if there are quotes and shit around it.
what sponsor?
Confined is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-06-2012, 03:40 PM   #3
RazorSharpe
Confirmed User
 
RazorSharpe's Avatar
 
Industry Role:
Join Date: Aug 2001
Location: Scotland
Posts: 2,238
Quote:
Originally Posted by Confined View Post
PHP Code:
$preg '@';
          
$preg .= '([a-zA-Z0-9 \!\&\.\/\'\"\#\&\;\_\-\:]+)'//title
          
$preg .= '[\s\r\n\f]*'//newline u want to avoid
          
$preg .= '\|([A-Za-z0-9 \?\/#\;\,\.\:\&\!\'\"]*)'//descr 
          
          
$preg .= '\|([a-zA-Z0-9 \?\,\&\.\/\_\-\:=]+)'//siteurl 
          
$preg .= '\|([A-Za-z0-9 \/\,\.\:\&\;\!\'\"]*)'//tags
          
$preg .= '[\s\t\r\n\f]+'//endofline
          
$preg .= '@i'
as a start. itll be different if there are quotes and shit around it.
what sponsor?
Hi,

There are quotes around the title that need to be removed. The sponsor is pimproll.

The description, site url, and the rest are just fine, all I need to do is remove quote before title, remove a line break just after title and remove a quote that closes off the title

Basically looking to make this:

"title
"|
into this:
title|

Cheers
__________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
RazorSharpe is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-06-2012, 03:52 PM   #4
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
icq: 33375924 if you want to invest a few bucks...
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-06-2012, 04:13 PM   #5
Confined
Registered User
 
Industry Role:
Join Date: Jan 2006
Posts: 93
PHP Code:
$preg '@';
          
$preg .= '[\"]*([a-zA-Z0-9 \!\&\.\/\'\"\#\&\;\_\-\:]+)'//title
          
$preg .= '[\s\r\n\f\"]*';
          
$preg .= '\|([A-Za-z0-9 \?\/#\;\,\.\:\&\!\'\"]*)'//descr 
          
          
$preg .= '\|([a-zA-Z0-9 \?\,\&\.\/\_\-\:=]+)'//siteurl 
          
$preg .= '\|([A-Za-z0-9 \/\,\.\:\&\;\!\'\"]*)'//tags
          
$preg .= '[\s\t\r\n\f]+'//end
          
$preg .= '@i'
let me know how that goes. i'm assuming you already have the preg_match_all statement somewhere, or you need a full on solution to parsing it?
Confined is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-06-2012, 11:11 PM   #6
iwantchixx
Too lazy to set a custom title
 
iwantchixx's Avatar
 
Industry Role:
Join Date: Oct 2002
Location: The Boonies
Posts: 12,860
use the macros in Textpad. Should only take 5 mins to go through it all once you create a workable macro (which should take only a few seconds)
iwantchixx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.