GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Help with regular expression (https://gfy.com/showthread.php?t=1070574)

RazorSharpe 06-06-2012 02:51 PM

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

Confined 06-06-2012 03:10 PM

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?

RazorSharpe 06-06-2012 03:40 PM

Quote:

Originally Posted by Confined (Post 18990541)
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

woj 06-06-2012 03:52 PM

icq: 33375924 if you want to invest a few bucks...

Confined 06-06-2012 04:13 PM

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?

iwantchixx 06-06-2012 11:11 PM

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)


All times are GMT -7. The time now is 04:34 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123