Skip to content

Commit 40d7e53

Browse files
authored
QueryNormalizer: Fix support for brackets, number followed by variable, pi and sqrt function.
1 parent df87392 commit 40d7e53

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/QueryNormalizer.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ class QueryNormalizer
2020
'(\d)\s+(\d)' => '$1$2',
2121
'(\d)(\*{2,}|\˘)(\d)' => '$1^$3',
2222
'(\d)\s*(\:|÷)\s*(\d)' => '$1/$3',
23+
'(^|[^\d\,])(\d+)\,((?:\d{3}\s*)+)($|[^\d\,])' => '$1$2$3$4',
2324
'(^|[^\d\,])(\d+)\,(\d+)($|[^\d\,])' => '$1$2.$3$4',
24-
'(\d)\s+([a-z])' => '$1$2',
25+
'(\d)\s+(\p{L})([^\p{L}]|$)' => '$1$2$3',
2526
'\+\-' => '-',
2627
'(\d+)\s*plus\s*(\d+)' => '$1+$2',
2728
'(\d+)\s*(krát|krat)\s*(\d+)' => '$1*$3',
2829
'\s*([\+\-\*\/\^])\s*' => '$1',
29-
'(\d)([xyz])' => '$1*$2',
30+
'(\d)(\p{L})([^\p{L}]|$)' => '$1*$2$3',
3031
'(nekonecno|nekonečno|infty|infinity|[iI][nN][fF]|∞)' => 'INF',
31-
'(π|[pP][iíI])' => 'PI',
32+
'(π|(?:\\\\)?[pP][iíI])' => 'PI',
33+
'\\\\frac{([^{}]+)}{([^{}]+)}' => '($1)/($2)',
34+
'([^\p{L}]|^)\((-?[\d\.]+)\)' => '$1$2',
3235
'\s*\=\s*' => '=',
3336
'×' => '*',
3437
'[–−]+' => '-',
3538
'(\d)\(' => '$1*(',
36-
'([√√]|odmocnina|odm|sqrt)(?:\s(?:ze|z))?\(?' => 'sqrt(',
39+
'([√√]|odmocnina|odm|sqrt)(?:\s(?:ze|z))?\s*\(?' => 'sqrt(',
3740
'\)\(' => ')*(',
3841
'\|([^|]+)\|' => 'abs($1)',
3942
'\s*(vs\.?)\s*' => ' $1 ',

0 commit comments

Comments
 (0)