Displaying page
of
pages;
Items to
Title |
Test
Details
Match substrings of string seprated by spaces while keeping substring groups enclosed by certain character(s) together.
|
Expression |
\S*?[\["].*?[\]"]|\S+
|
Description |
Given that you have a string that is comprised characters/words separated by spaces and you want to creates matches of those words/characters but you also have substring groups of words/characters/spaces enclosed in [] and "" that you want treated as a single match, this pattern is what worked for me. Feel free to modify this regex to fit your needs if your string groups are not grouped by [] or "". Please let me know if this doesn't test well for you. ********** Example Test String:
212.183.143.4 - - [03/May/2007:21:03:27 +0100] "GET mp4-amrnb.3gp RTSP/1.0" 200 155527 [RealOnePlayer_s60.26.25.01_21-Jun-2005_13:02:43_epoc_av21_thumb] [3e546ed1-f9b1-11db-eb72-1d98b80ca9f5] [UNKNOWN] 454492 102 47 0 0 [0 0 0 0] [03/May/2007:21:02:38] 192.168.0.2 24245 55 ********** Matches:
Matches(0) = "212.183.143.4"
Matches(1) = "-"
Matches(2) = "-"
Matches(3) = "[03/May/2007:21:03:27 +0100]"
Matches(4) = ""GET mp4-amrnb.3gp RTSP/1.0""
Matches(5) = "200"
Matches(6) = "155527"
Matches(7) = "[RealOnePlayer_s60.26.25.01_21-Jun-2005_13:02:43_epoc_av21_thumb]"
Matches(8) = "[3e546ed1-f9b1-11db-eb72-1d98b80ca9f5]"
Matches(9) = "[UNKNOWN]"
Matches(10) = "454492"
Matches(11) = "102"
Matches(12) = "47"
Matches(13) = "0"
Matches(14) = "0"
Matches(15) = "[0 0 0 0]"
Matches(16) = "[03/May/2007:21:02:38]"
Matches(17) = "192.168.0.2"
Matches(18) = "24245"
Matches(19) = "55"
********** ASP Test Code:
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.MultiLine = True
teststring = "<<your string>>"
regEx.Pattern = "\S*?[\[|\""].*?[\]|\""]|\S+"
Set Matches = regEx.Execute(teststring)
|
Matches |
any [strings matched] "any at" all
|
Non-Matches |
^\s*$
|
Author |
Rating:
Not yet rated.
Doug Drudik
|
Title |
Test
Details
Permutations of a character series
|
Expression |
(?!.*([abcde]).*\1)^[abcde]{5}$
|
Description |
Let's say that you have a series of characters "abcde" and you want to match all strings that could be comprised of those characters with each character used exactly once. This could loosely be termed an anagram matcher, although if the string contains duplicate letters it would require modification of this pattern. In the example case we have a string "abcde" and we want to match any permutation of "abcde". Note that the "5" used in the pattern indicates the number of characters specified in the character set "abcde", "5" would still be used if "abcde" would be replaced with "a-e" since there would still be 5 characters in the series. If you are curious about how to require duplicates in the pattern (to match all permutations of "apple" for example) I would use (?=^.*p.*p$)(?!.*([ale]).*\1)^[aple]{5}$
|
Matches |
abcde | dbcae | edcba
|
Non-Matches |
abcbe
|
Author |
Rating:
Doug Drudik
|
Displaying page
of
pages;
Items to