Jump to content

Regex code does not work at all


a123123

Recommended Posts

Hello

I have the following code:

<?php
$patterns = array('/(?s)(?<=\s)(\s|,|\\\|\^|\(|\)|\[(?!t)|(?<!t)\]|{|}|0-9|\-|\=|\+|b|c|d|f|g|h|j|k|l|m|n|p|r|s|(?<!t)x|B|C|D|F|G|H|J|K|L|M|N|P|R|S|T|X|.\(.\)|)+(?=(\s|\.)(??!\[\/t\]).|\n)*\[te\])/');
$replacements = array('[t]$1[/t]');
$string=$_POST['kod'];
echo preg_replace($patterns, $replacements, stripslashes($string));
?>

I want it to:

1) dot matches newline

2) every string which is followed by space or newline and contains: coma, backslash \, ^, (, ), [, ], {, }, digits, -, =, +, small and big letters, every .(.) series, and is between [/t] and [t] characters (example: [/t] ... string ... [t]), would be changed to [t]$1[/t]. But it doesn't work - only newlines are changed. Where is a problem?

Link to comment
https://forums.phpfreaks.com/topic/264608-regex-code-does-not-work-at-all/
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.