- Регистрация
- 04.11.2010
- Сообщения
- 2 382
- Реакции
- 917
- Баллы
- 113
We collect the people's list of regulars (regex) for all occasions, I'll start first. Who has their own - throw, add to the first post indicating the author. Regulars can sometimes work incorrectly, if that write off in this thread - we will find a solution.
[TABLE="class: brtb_item_table, border-width: 4px"][TBODY][TR][TH]List of regular expressions and typical usage contexts[/TH][/TR]
[TR][TD]Search for a number greater than 0
Use case:
In this example, the visible elements are searched for only, the invisible elements (having a width of 0px) are ignored, but sometimes there are misfires - when a site overlays elements (it is found in Google for example).
Thanks: CSS, ZennoScript[/TD][/TR]
[TR][TD] Parsing the text for sentences, seems author is ZennoScript, I have slightly modified
work example, initial data:
Thanks: ZennoScript[/TD][/TR]
[TR][TD]Search for a word starting with a specific text (Thank ZennoScript for the modification)
Find in the text all the words beginning with go, for example: goal, god, google
Thanks: CSS, ZennoScript[/TD][/TR]
[TR][TD]Searches for a number in the range 400-699:
more about the range you can see here http://www.regular-expressions.info/numericranges.html
Shared: CSS[/TD][/TR]
[TR][TD]Virtual columns with separator ";"
initial data: name;pass;mail
result: the "column" you need by the match number:
Посмотреть вложение 8857
use case: we work with the list, we disassemble by the pieces of the column as in the table
Shares: CSS[/TD][/TR]
[TR][TD]Get the file name from the windows path:
initial data:
Shared: CSS[/TD][/TR]
[TR][TD]Search for strings NOT containing the specified (sub) string:
initial data:
Shared: CSS[/TD][/TR]
[TR][TD]Take all the lines of more than 18 characters
Thanks: alekwuy[/TD][/TR]
[TR][TD]Get all lines less than 18 characters
Thanks: alekwuy[/TD][/TR]
[TR][TD]Search all HTML tags
Use case - clear text from HTML code
Thanks: Trader1985[/TD][/TR]
[TR][TD]Find all empty lines in the text
Use case - text correction
Thanks: Trader1985[/TD][/TR]
[TR][TD]Search from three or more blank lines
Use case - text correction if we are satisfied with 2 blank lines
Thanks: Trader1985[/TD][/TR]
[TR][TD]Email:
[/TD][/TR]
[TR][TD]IP
[/TD][/TR]
[TR][TD]URL
[/TD][/TR]
[TR][TD] IP
ORT (for example for parsing a proxy)
Thanks: up_lvl[/TD][/TR][/TBODY][/TABLE]
Origin: Link
Author: CSS
Translate by: LightWood
[TABLE="class: brtb_item_table, border-width: 4px"][TBODY][TR][TH]List of regular expressions and typical usage contexts[/TH][/TR]
[TR][TD]Search for a number greater than 0
Код:
(?<=(\D|^))[1-9]\d*
Use case:
In this example, the visible elements are searched for only, the invisible elements (having a width of 0px) are ignored, but sometimes there are misfires - when a site overlays elements (it is found in Google for example).
Thanks: CSS, ZennoScript[/TD][/TR]
[TR][TD] Parsing the text for sentences, seems author is ZennoScript, I have slightly modified
Код:
[А-ЯA-Z].{15,}?(\.|\!|\?)(?=\ |\r|\n|$)
work example, initial data:
result:Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce dapibus tellus nec nulla gravida, sed congue nunc hendrerit. Integer interdum elementum lorem id rutrum. Ut sit amet interdum mauris. Phasellus mollis ex eleifend lacus molestie dictum. Fusce blandit, ligula non condimentum maximus, massa nisi ullamcorper odio, et vehicula nisl nunc nec orci. Sed neque diam, gravida eu blandit ullamcorper, porttitor non lorem. Etiam sagittis diam a dolor feugiat placerat. Suspendisse enim turpis, imperdiet in tellus sit amet, consectetur porta magna. Suspendisse odio nulla, imperdiet eget augue in, pulvinar hendrerit nunc. Aenean ut cursus tellus, nec vehicula ante. Vestibulum ornare erat non ante tempus, eu aliquet felis dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris eget arcu imperdiet, laoreet erat non, imperdiet leo. Sed arcu mi, ornare non leo sed, faucibus semper nunc.
Thanks: ZennoScript[/TD][/TR]
[TR][TD]Search for a word starting with a specific text (Thank ZennoScript for the modification)
Код:
(?i)\bgo.*?(?=\W|\ |\r|\n|$)
Thanks: CSS, ZennoScript[/TD][/TR]
[TR][TD]Searches for a number in the range 400-699:
Код:
^([4-6][0-9][0-9])$
Shared: CSS[/TD][/TR]
[TR][TD]Virtual columns with separator ";"
Код:
(?<=(^|;)).*?(?=(;|$|\r\n))
result: the "column" you need by the match number:
Посмотреть вложение 8857
use case: we work with the list, we disassemble by the pieces of the column as in the table
Shares: CSS[/TD][/TR]
[TR][TD]Get the file name from the windows path:
Код:
([^\\]+$)
result: ZennoPoster.exeС:\Program Files (x86)\ZennoLab\ZennoPoster Pro\Progs\ZennoPoster.exe
Shared: CSS[/TD][/TR]
[TR][TD]Search for strings NOT containing the specified (sub) string:
Код:
(?<=(^|\r\n))((?!(test)).)*(?=($|\r\n))
result:test
tester
gogogo
ololo
gogogo
ololo
Shared: CSS[/TD][/TR]
[TR][TD]Take all the lines of more than 18 characters
Код:
(?<=(\r\n|^)).{18,}(?=(\r\n|$))
Thanks: alekwuy[/TD][/TR]
[TR][TD]Get all lines less than 18 characters
Код:
(?<=(\r\n|^)).{1,18}(?=(\r\n|$))
Thanks: alekwuy[/TD][/TR]
[TR][TD]Search all HTML tags
Код:
<.*?>
Thanks: Trader1985[/TD][/TR]
[TR][TD]Find all empty lines in the text
Код:
\n\r
Thanks: Trader1985[/TD][/TR]
[TR][TD]Search from three or more blank lines
Код:
(?<=(\r\n){2})(\r\n){1,}
Thanks: Trader1985[/TD][/TR]
[TR][TD]Email:
Код:
[\.\-_A-Za-z0-9]+?@[\.\-A-Za-z0-9]+?[\.A-Za-z0-9]{2,}
[TR][TD]IP
Код:
(\d{1,3}\.){3}\d{1,3}
[TR][TD]URL
Код:
(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
[TR][TD] IP
ORT (for example for parsing a proxy)
Код:
(\d{1,3}\.){3}\d{1,3}:\d*
Origin: Link
Author: CSS
Translate by: LightWood

