mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Allow including record indexes in regex pattern
This commit is contained in:
parent
228d3e9614
commit
3405d58c67
@ -296,6 +296,7 @@ class importexport_helper_functions {
|
||||
if ( empty( $conversion_string ) ) continue;
|
||||
|
||||
// fetch patterns ($rvalues)
|
||||
$rvalues = array();
|
||||
$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
|
||||
foreach( $pat_reps as $k => $pat_rep ) {
|
||||
list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
|
||||
@ -319,6 +320,16 @@ class importexport_helper_functions {
|
||||
}
|
||||
$c_functions = implode('|', $c_functions);
|
||||
foreach ( $rvalues as $pattern => $replace ) {
|
||||
// Allow to include record indexes in pattern
|
||||
$reg = '/\|\[([0-9]+)\]/';
|
||||
while( preg_match( $reg, $pattern, $vars ) ) {
|
||||
// expand all _record fields
|
||||
$pattern = str_replace(
|
||||
$CPre . $vars[1] . $CPos,
|
||||
$_record[array_search($vars[1], array_keys($_record))],
|
||||
$pattern
|
||||
);
|
||||
}
|
||||
if( preg_match('/'. (string)$pattern.'/', $val) ) {
|
||||
|
||||
$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
|
||||
|
Loading…
Reference in New Issue
Block a user