Regular expression: Difference between revisions

From Planfix
Jump to: navigation, search
No edit summary
No edit summary
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Regular expressions in rules for processing emails allow you to isolate a desired fragment of text when extracting data from an email.
{{#seo:
 
|title=Regular expression in Planfix
|titlemode=append
|keywords=planfix, regular expression, rules, email, task, extracting data from the email
|description=Using regular expressions in Planfix
}}
'''Regular expressions''' in [[Rules for creating tasks by email | rules for processing emails]] allow you to isolate a desired fragment of text when [[Email rules: Extracting data | extracting data]] from an email.
== Important ==
== Important ==
*The use of regular expressions typically requires programming skills. If you don't know any programming languages, you should ask for help.
*The use of regular expressions typically requires '''programming skills'''. If you don't know any programming languages, you should ask for help.
 
*In Planfix, regular expressions operate with the Pattern.DOTALL and Pattern.MULTILINE options. For validation, you can use the [https://regex101.com/online validator] — [https://p.pfx.so/pf/nG/2iUOoF.png gms]
 
*Regular expressions can also be used with the [[REGEXPFIND Function]].
== Formatting regular expressions ==
== Formatting regular expressions ==
Planfix uses the regular expression format used in Java. The syntax of regular expressions uses the symbols <([{\^-=$!|]})?*+.>, which can be combined with letters to create metacharacters. The most frequently used metacharacters are listed in this table:
Planfix uses the regular expression format used in Java. The syntax of regular expressions uses the symbols <([{\^-=$!|]})?*+.>, which can be combined with letters to create metacharacters. The most frequently used metacharacters are listed in this table:
{| class="wikitable" style="text-align: center;"
{| class="wikitable" style="text-align: center;"
|-
|-
! Метасимвол !!                                              Назначение
! Metacharacter !!                                              Meaning
|-
|-
|  <nowiki> ^ </nowiki> ||  начало строки
|  <nowiki> ^ </nowiki> ||  beginning of input
|-
|-
|  <nowiki> $  </nowiki> ||  конец строки
|  <nowiki> $  </nowiki> ||  end of input
|-
|-
|  <nowiki> \d    </nowiki> ||  цифровой символ
|  <nowiki> \d    </nowiki> ||  digit
|-
|-
|  <nowiki> \D    </nowiki> ||  нецифровой символ
|  <nowiki> \D    </nowiki> ||  non-digit character
|-
|-
|  <nowiki> \s    </nowiki> ||  символ пробела
|  <nowiki> \s    </nowiki> ||  space character
|-
|-
|  <nowiki> \S    </nowiki> ||  непробельный символ
|  <nowiki> \S    </nowiki> ||  non-space character
|-
|-
|  <nowiki> \w    </nowiki> ||  буквенно-цифровой символ или знак подчёркивания  
|  <nowiki> \w    </nowiki> ||  alphanumeric character or underscore  
|-
|-
|  <nowiki> \W    </nowiki> ||  любой символ, кроме буквенного, цифрового или знака подчёркивания
|  <nowiki> \W    </nowiki> ||  any character except alphanumerics and underscores
|-
|-
|  <nowiki> .  </nowiki> ||  любой символ
|  <nowiki> .  </nowiki> ||  any character
|-
|-
|  <nowiki> \t    </nowiki> ||  символ табуляции
|  <nowiki> \t    </nowiki> ||  tab character
|-
|-
|  <nowiki> \n    </nowiki> ||  символ новой строки  
|  <nowiki> \n    </nowiki> ||  newline symbol  
|-
|-
|  <nowiki> \r    </nowiki> ||  символ возврата каретки
|  <nowiki> \r    </nowiki> ||  carriage return symbol
|-
|-
|  <nowiki> [абв]    </nowiki> ||  любой из перечисленных (а,б, или в)  
|  <nowiki> [abc]    </nowiki> ||  any of the characters listed (a, b, or c)
|-
|-
|  <nowiki> [^абв]    </nowiki> ||  любой, кроме перечисленных (не а,б, в)  
|  <nowiki> [^abc]    </nowiki> ||  any character except those listed (not a, b, or c)
|-
|-
|  <nowiki> [a-zA-Z]    </nowiki> ||  слияние диапазонов (латинские символы от a до z без учета регистра)  
|  <nowiki> [a-zA-Z]    </nowiki> ||  multiple ranges (Latin characters from A to Z, case-insensitive)  
|-
|-
|  <nowiki> [a-d[m-p]]    </nowiki> ||  объединение символов (от a до d и от m до p)  
|  <nowiki> [a-d[m-p]]    </nowiki> ||  combining characters (from a to d and from m to p)  
|-
|-
|  <nowiki> [a-z&&[def]]    </nowiki> ||  пересечение символов (символы d,e,f)  
|  <nowiki> [a-z&&[def]]    </nowiki> ||  overlapping characters (d, e, f)  
|-
|-
|  <nowiki> [a-z&&[^bc]]    </nowiki> ||  вычитание символов (символы a, d-z)  
|  <nowiki> [a-z&&[^bc]]    </nowiki> ||  subtracting characters (a, d-z)  
|-
|-
|  <nowiki> ?  </nowiki> ||  один или отсутствует
|  <nowiki> ?  </nowiki> ||  one or not exist
|-
|-
|  <nowiki> *  </nowiki> ||  ноль или более раз  
|  <nowiki> *  </nowiki> ||  match zero or one  
|-
|-
|  <nowiki> +  </nowiki> ||  один или более раз
|  <nowiki> +  </nowiki> ||  one or more times
|-
|-
|  <nowiki> {n}  </nowiki> ||  n раз
|  <nowiki> {n}  </nowiki> ||  n times
|-
|-
|  <nowiki> {n,}  </nowiki> ||  n раз и более  
|  <nowiki> {n,}  </nowiki> ||  n or more times  
|-
|-
|  <nowiki> {n,m}    </nowiki> ||  не менее n раз и не более m раз
|  <nowiki> {n,m}    </nowiki> ||  at least n times and no more than m times
|-
|-
|}
|}
 
== Helpful information ==
 
*The result of text processing using a regular expression becomes the first capturing group. Accordingly, what is needed in the result should be enclosed in parentheses, and the rest of the groups should be made non-capturing '''(?:)'''
 
 
== Полезная информация ==
*В результат обработки текста при помощи регулярного выражения попадает первая capturing группа. Соответственно, то, что нужно, чтобы было в результате надо взять в скобки, а остальные группы сделать non-capturing '''(?:)'''
*Больше о работе регулярных выражений можно прочитать в [https://javarush.ru/groups/posts/regulyarnye-vyrazheniya-v-java этой статье].
 




Line 74: Line 73:
*[[Creating and editing rules]]
*[[Creating and editing rules]]
*[[Rules for creating tasks by email]]
*[[Rules for creating tasks by email]]
*[[Feature Description]]

Latest revision as of 08:20, 28 October 2024

Regular expressions in rules for processing emails allow you to isolate a desired fragment of text when extracting data from an email.

Important

  • The use of regular expressions typically requires programming skills. If you don't know any programming languages, you should ask for help.
  • In Planfix, regular expressions operate with the Pattern.DOTALL and Pattern.MULTILINE options. For validation, you can use the validatorgms
  • Regular expressions can also be used with the REGEXPFIND Function.

Formatting regular expressions

Planfix uses the regular expression format used in Java. The syntax of regular expressions uses the symbols <([{\^-=$!|]})?*+.>, which can be combined with letters to create metacharacters. The most frequently used metacharacters are listed in this table:

Metacharacter Meaning
^ beginning of input
$ end of input
\d digit
\D non-digit character
\s space character
\S non-space character
\w alphanumeric character or underscore
\W any character except alphanumerics and underscores
. any character
\t tab character
\n newline symbol
\r carriage return symbol
[abc] any of the characters listed (a, b, or c)
[^abc] any character except those listed (not a, b, or c)
[a-zA-Z] multiple ranges (Latin characters from A to Z, case-insensitive)
[a-d[m-p]] combining characters (from a to d and from m to p)
[a-z&&[def]] overlapping characters (d, e, f)
[a-z&&[^bc]] subtracting characters (a, d-z)
 ? one or not exist
* match zero or one
+ one or more times
{n} n times
{n,} n or more times
{n,m} at least n times and no more than m times

Helpful information

  • The result of text processing using a regular expression becomes the first capturing group. Accordingly, what is needed in the result should be enclosed in parentheses, and the rest of the groups should be made non-capturing (?:)


Go To