Difference between revisions of "Regular expression"
Line 4: | Line 4: | ||
An online regular expression tester can also be used to verify the correctness of the regular expression: https://regex101.com/ | An online regular expression tester can also be used to verify the correctness of the regular expression: https://regex101.com/ | ||
+ | |||
+ | == Configurable device drivers == | ||
+ | In {{RadiMation}} the [[Regular expression]]s are often used to interpret the response of a device. Several configurable device drivers, provide a possibility to specify the regular expression to convert the response on a query-command into a value. | ||
+ | |||
+ | A small regular expression validator is also included to check if the regular expression will be working correctly to interpret the response of the device. | ||
+ | |||
+ | === Regular expression examples === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Received information | ||
+ | ! Regular expression | ||
+ | ! Determined measurement value | ||
+ | ! Note | ||
+ | |- | ||
+ | | U_L_N 325 | ||
+ | | (-?[0-9.,Ee-]+) | ||
+ | | 325 | ||
+ | | Takes the first number. | ||
+ | |- | ||
+ | | I_L1;12.34 | ||
+ | | ;(-?[0-9.,Ee-]+) | ||
+ | | 12.34 | ||
+ | | Takes the first number after ";". | ||
+ | |- | ||
+ | | THD_U_L1;;14,5 | ||
+ | | ;;(-?[0-9.,Ee-]+) | ||
+ | | 14.5 | ||
+ | | Takes the first number after ";;". | ||
+ | |- | ||
+ | | AC_FREQ;Channel1;1.23E3 | ||
+ | | ;.*;(-?[0-9.,Ee-]+) | ||
+ | | 1230 | ||
+ | | Takes the first number after the appearance of a second ";". | ||
+ | |} | ||
+ | |||
+ | The correctness of the regular expression can be tested and improved by using the {{ScreenElement|Validate Expression}} tool. | ||
+ | |||
+ | [[File:ValidateExpressionTool.png]] | ||
== Links == | == Links == |
Revision as of 15:27, 30 January 2023
A Regular expression is a text pattern that describes how textual input should be parsed to retrieve a piece (or complete) of the textual input.
For regular expression we advise you to look at an internet site dedicated to regular expressions: http://www.regular-expressions.info/tutorial.html
An online regular expression tester can also be used to verify the correctness of the regular expression: https://regex101.com/
Configurable device drivers
In RadiMation® the Regular expressions are often used to interpret the response of a device. Several configurable device drivers, provide a possibility to specify the regular expression to convert the response on a query-command into a value.
A small regular expression validator is also included to check if the regular expression will be working correctly to interpret the response of the device.
Regular expression examples
Received information | Regular expression | Determined measurement value | Note |
---|---|---|---|
U_L_N 325 | (-?[0-9.,Ee-]+) | 325 | Takes the first number. |
I_L1;12.34 | ;(-?[0-9.,Ee-]+) | 12.34 | Takes the first number after ";". |
THD_U_L1;;14,5 | ;;(-?[0-9.,Ee-]+) | 14.5 | Takes the first number after ";;". |
AC_FREQ;Channel1;1.23E3 | ;.*;(-?[0-9.,Ee-]+) | 1230 | Takes the first number after the appearance of a second ";". |
The correctness of the regular expression can be tested and improved by using the Validate Expression tool.
Links
- Wikipedia: Regular Expression
- Regular expression tutorial: http://www.regular-expressions.info/tutorial.html
- Regular epxression tester: https://regex101.com/