Apache Pig Latin using matches - apache-pig

I am trying with Apache Pig latin to FILTER url which matches particular pattern.
for ex:
**http://www.example.com/homePage.do?locale=en_US
I want to filter all the URL that matches
locale=en_US (or)
locale=en_CA
Please need help on resolving this.

You can use url matches '.*(locale=en_US|locale=en_CA).*'
It is good also to look at https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html when using regex in Pig

Related

pycharm(any IntelliJ product), how to add certain partern to the regex search result

I find what I want by using regex search, let's say I find all the telphone numbers in my file using regex and then I want to add a string "(+1)" in front of the results I found. What should I put in the "replace" input?
Is this possible? I searched a lot but all I found is that how to use regex and replace the whole stuff.

How can i query for specific matching substrings while ignoring the rest in a SCAN query?

trying to do a redis SCAN command and trying to figure out how to do glob-pattern substring matching for words instead of single characters (using ruby redis gem)
redis.set("first:url:123", "val1")
redis.set("second:url:123", "val2")
redis.set("third:url:123", "val3")
redis.set("fourth:url:123", "val4")
cursor = 0
pattern = "[first,second]:url:*" ## I only want the first and second keys
redis.scan(cursor, match: pattern)
# => ...
--
according to the docs here i found these available options but it looks like it only works for single characters, how can i use it for words?
h[ae]llo matches hello and hallo, but not hillo
Edit:
https://globster.xyz/
makes me think that using {first,second}:url:123 should work, but that doesnt seem to work either
Redis doesn't support regex expressions for key name patterns, only glob-like expressions.
You can revert to an EVAL Lua script if you are amendment about it. Here's one that does it, but do read the comments: https://gist.github.com/itamarhaber/19c8393f465b62c9cfa8

Mule File matcher excluding a pattern

I am trying to write a GLOB pattern to exclude a partially downloaded file to be read by the File Listener. I am using the file name pattern foo.*[^filepart] in the File matcher but it doesn't works.
Please suggest.
<file:matcher name="filename-regex-filter" doc:name="Matcher" doc:id="410af88e-b6c6-4816-aaff-1f4edc29214f" filenamePattern="foo.*[^filepart]" />
filenamePattern is a regular expression. In regular expressions the pattern [^abc] excludes any of the set of characters after ^.
For example abc[^def] matches abcd, abce and abcf, but it doesn't match abcdef.
The answer is in previous questions about how to exclude words in regular expressions: https://stackoverflow.com/a/1333787/721855 or https://stackoverflow.com/a/2078953/721855. Use the (?!X) expression instead.
Example: foo.*(?!filepart)

How to write a redis scan command to match either of two patterns

I want to use HSCAN match clause to match a key which is of type 1 or type 2. A regex would be like ^match1|^match2. Is it possible to do this in glob style pattern.
Redis does not offer a straight forward way to match multiple patterns.
Redis matchs using glob-style pattern which is very limited.
Supported glob-style patterns:
h?llo matches hello, hallo and hxllo
h*llo matches hllo and heeeello
h[ae]llo matches hello and hallo, but not hillo
h[^e]llo matches hallo, hbllo, ... but not hello
h[a-b]llo matches hallo and hbllo
Use \ to escape special characters if you want to match them verbatim.
You can't use glob-style for that, but you can Lua your way around this. That means you can use
EVAL and a script (can be similar to https://github.com/itamarhaber/redis-lua-scripts/blob/master/scanregex.lua) for performing the HSCAN match1* first, and then filtering with Lua on match2.*.

Selenium: Part of text present

Is there a way to verify only part of text present?
If there is a text "Warning: A15P09 has not been activated." I need to verify the text is present. However, 'A15P09' is not always the same, so I cannot do something like
Selenium.IsTextPresent("Warning: A15P09 has not been activated.");
I might do something like:
Selenium.IsTextPresent("has not been activated.");
But is there another way to verify this in Selenium. Please let me know if there is.
Thanks!
You could use getText and then do any normal regex that your language supplies for examining that result.
Edit: And for some languages you can do isTextPresent on a pattern modified string. The documentation states:
Various Pattern syntaxes are available
for matching string values:
glob:pattern: Match a string against a
"glob" (aka "wildmat") pattern. "Glob"
is a kind of limited
regular-expression syntax typically
used in command-line shells. In a glob
pattern, "*" represents any sequence
of characters, and "?" represents any
single character. Glob patterns match
against the entire string.
regexp:regexp: Match a string using a
regular-expression. The full power of
JavaScript regular-expressions is
available.
exact:string: Match a
string exactly, verbatim, without any
of that fancy wildcard stuff.
If no
pattern prefix is specified, Selenium
assumes that it's a "glob" pattern.