Recent Topics

1 Oct 23, 2007 16:41    

See: [url=http://forums.b2evolution.net/viewtopic.php?t=13069&start=0&postdays=0&postorder=asc&highlight=][1.10.x] Quotation marks conversion from "ticks"[/url].

Please do change CSV.

Thanks,

ƒ

2 Oct 23, 2007 18:54

Come up with the bullet proof answer and I'll make the changes ;)

¥

3 Oct 24, 2007 01:49

$curl = preg_replace('/"(\s|\Z|[\.,\?!;:\)\]}]\s|[\.,\?!;:\)\]}]\Z)/', '& #8221;$1', $curl);


minus the space after &
and

$curl = preg_replace("/'(\s|\Z|[\.,\?!;:\)\]}]\s|[\.,\?!;:\)\]}]\Z)/", '& #8217;$1', $curl);


once again minus the space after &.

This seems to work just fine but any feedback is appreciated.

ƒ

4 Oct 24, 2007 11:18

You could probably ( untested of course ;) ) reduce both those to :

$curl = preg_replace('/["\'](\s|\Z|[\.,\?!;:\)\]}]\s|[\.,\?!;:\)\]}]\Z)/', '& #8221;$1', $curl);

I'd need to have a play with some sample data to be sure it all works as expected ;)

¥

5 Oct 24, 2007 13:04

I was wonderimng if this works:

$curl = preg_replace("/'(\s|\Z|[\.,\?!;:\)\]}][\s\Z])/", '& #8217;$1', $curl);

6 Oct 24, 2007 13:28

See [url=http://blog.hemminga.net/index.php?blog=9]my testblog[/url].

1) The closing single quotation marks seem to work regardles of the line:

$curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl);


so it can be deleted

2) My last proposal seems to work :p

Happy editing

ƒ

7 Oct 24, 2007 13:43

This is a few characters shorter and it still works:

$curl = preg_replace('/"([\.,\?!;:\)\]}]?[\s\Z])/', '& #8217;$1', $curl);


It doesn't come mutch leaner than this unless you do:

$curl = preg_replace('/"(.?[\s\Z])/', '& #8217;$1', $curl);

--ƒ

8 Oct 24, 2007 13:47

I am fascinated by this, but you may have noticed. :lol:

--ƒ

9 Oct 24, 2007 15:03

Hi Afwas,
Compare the two outputs :

<?php
$fred = '"hello world!", said "Fred". Unfortunately he\'d a problem of thinking of a sentence that involved ";" so he "went home";-p';

$peter = preg_replace( array(
	'~((\w)["\'](\W))|((\W)["\'](\w))|((\W)["\'](\W))~', // find any " or ' within sentance
	'~^["\']~', // find any " or ' at start of line
	'~["\']$~' // find any " or ' at end of line
	 ) ,array( '$2$5$8<quote>$3$6$9', '<quote>', '<quote>' ), $fred );

$john  = preg_replace('/"([\.,\?!;:\)\]\}]?[\s\Z])/', '<quote>$1', $fred); 
echo 'Peter : '.$peter.'<br />John : '.$john;
?>

Peter : <quote>hello world!<quote>, said <quote>Fred<quote>. Unfortunately he'd a problem of thinking of a sentence that involved <quote>;" so he <quote>went home<quote>;-p
John : "hello world!<quote>, said "Fred<quote>. Unfortunately he'd a problem of thinking of a sentence that involved ";<quote> so he "went home";-p

¥

10 Oct 24, 2007 16:08

¥åßßå wrote:

Hi Afwas,
Compare the two outputs :

¥

We're talking *closing* quotation marks only. The second example looks ok, but it misses the last " and it should because there is no space or end of string after ; but a -. If you insert a space before -p it should find the last quote also.

--ƒ

11 Oct 24, 2007 16:37

Ah, now you make sense .... can you tell I don't use the texturiser plugin? :roll:

How about a combination of the two ;)

echo preg_replace('/("([\.,\?!;:\)\]}]?[\s\Z]))|(\w)"(\W)/', '$3[quote]$2$4', $fred);

¥

*edit*
or

preg_replace('/("(\W?[\s\Z]))|(\w)"(\W)/', '$3[quote]$2$4', $fred);

12 Oct 24, 2007 19:30

¥åßßå wrote:

Ah, now you make sense ....

I do not agree with you. I made sense all along.
¥åßßå wrote:

can you tell I don't use the texturiser plugin? :roll:

You should:

$cockney = array ("'tain't", "'twere", "'twas", "'tis","'twill", "'til", "'bout", "'nuff", "'round");
$cockneyreplace = array ("’tain’t", "’twere", "’twas", "’tis", "’twill", "’til", "’bout", "’nuff", "’round");
$curl = str_replace($cockney, $cockneyreplace, $curl);

Your last example is about the right combination of grace and functionality, but I could live without the (\w)"(\W)
and even with .? in stead of \W? and -perhaps- even (\w)" in stead of (\w)"(\W)

--ƒ

*edit*
how 'bout:

(\w)(\W)"(\W)


I start to dislike phpBB:
(\w)(\W)"(\W)

13 Oct 24, 2007 19:50

Afwas wrote:

¥åßßå wrote:

Ah, now you make sense ....

I do not agree with you. I made sense all along.

You need to learn blonde :P

Afwas wrote:

You should:

$cockney = array ("'tain't", "'twere", "'twas", "'tis","'twill", "'til", "'bout", "'nuff", "'round");
$cockneyreplace = array ("’tain’t", "’twere", "’twas", "’tis", "’twill", "’til", "’bout", "’nuff", "’round");
$curl = str_replace($cockney, $cockneyreplace, $curl);

We may have a smidge of a small patch of dirt to loiter on, but I'm not a cockney :P

Afwas wrote:

Your last example is about the right combination of grace and functionality, but I could live without the (\w)"(\W)
and even with .? in stead of \W? and -perhaps- even (\w)" in stead of (\w)"(\W)

--ƒ

Without sounding funny :

¥åßßå wrote:

Come up with the bullet proof answer and I'll make the changes ;)

¥

Otherwise we'll be answering support threads in the forums for years huh?

Afwas wrote:

I am fascinated by this, but you may have noticed. :lol:

--ƒ

Hell yeah, isn't that why we all do it? :D

¥

.... after yer edit
I'll have to test that when I get a moment ;)

15 Oct 24, 2007 19:54

or (\w)(\W)?"(\W)? to replace everything as in:
$curl = preg_replace('/(\w)(\W)?"(\W)?/', '& #8217;$1', $curl);

16 Oct 24, 2007 19:59

<?php
$fred = '"hello world!", said "Fred". Unfortunately he\'d a problem of thinking of a sentence that involved ";" so he "went home";-p';

$john  = preg_replace('/(\w)(\W)?"(\W)?/', '$1$2[quote]$3', $fred); 
echo 'John : '.$john;
?>

Changes open quotes as well ;)

¥

18 Oct 24, 2007 20:26

<?php
$fred = '"hello world!", said "Fred". Unfortunately he\'d a problem of thinking of a sentence that involved ";" so he "went home";-p';

$john  = preg_replace('/("(\W?[\s\Z]))|(\w)"(\W)/', '[quote]$1', $fred); 
echo 'John : '.$john;
?>

Removes the end char of the replace when it's an alpha char?
¥

19 Oct 24, 2007 20:34

¥åßßå wrote:

Removes the end char of the replace when it's an alpha char?
¥

Yes

$curl = preg_replace('/"(.?[\s\Z])/', '& #8221;$1', $curl);
/* $curl = preg_replace("/'([\s.]|\Z)/", '& #8217;$1', $curl); */

John says: I don't like home";-p
Testlab says: ok

$curl = preg_replace('/"(\W?[\s\Z])/', '& #8221;$1', $curl);
/* $curl = preg_replace("/'([\s.]|\Z)/", '& #8217;$1', $curl); */

John says: I don't like home";-p and loses spaces
Testlab says: ok

$curl = preg_replace('/"[\W\s\Z]/', '& #8221;$1', $curl);
/* $curl = preg_replace("/'([\s.]|\Z)/", '& #8217;$1', $curl); */

John says: major problems
Testlab says: major problems

$curl = preg_replace('/"(\s|\Z|[\.,\?!;:\)\]}]\s|[\.,\?!;:\)\]}]\Z)/', '& #8221;$1', $curl);
/* $curl = preg_replace("/'([\s.]|\Z)/", '& #8217;$1', $curl); */

John says: I don't like home";-p and loses spaces
Testlab says: ok

20 Oct 27, 2007 18:50

Sorry Afwas, I got distracted with torching yet another servers cpu, where are we up to so far with the best answer?

¥


Form is loading...