Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account
List archives

Using Regex

Using Regex in Embedded Pig in Java
(32 lines)
Re: pig + BigDecimal + DataType
(84 lines)
Jul 20, 2010
Matthew Smith
Matthew Smith
All,

 

I am using pig embedded in Java and need to use matches in my pig job.
However when I try to use escape characters in the pig line, the
compiler complains. How do I use complex regex while embedding?

 

Sample code that is throwing errors:

 

myServer.registerQuery("filtered = FILTER firstcut BY dIP matches
'\Q34.21.12.*\E';");

 

error: invalid escape sequence.

 

Thanks,

 

Matt

 



Reply
Tags: pigembeddedcodesample
Messages in this thread
Using Regex
reply RE: Using Regex
(46 lines) Jul 20, 2010 16:14
reply RE: Using Regex
(100 lines) Jul 20, 2010 16:39
reply Re: Using Regex
(123 lines) Jul 20, 2010 17:05
reply RE: Using Regex
(132 lines) Jul 20, 2010 17:31
Similar Threads
Ask a question about regex in CRS
Hi, everyone
    The following rule comes from
rules/base_rules/modsecurity_crs_41_sql_injection_attacks.conf , but I
don't understand what does the regular expression "(?:[\\\(\)\%#]|--)"
mean. What's the meaning of "\%" in a regex?

SecRule MATCHED_VAR "(?:[\\\(\)\%#]|--)"
        
"t:none,setvar:'tx.msg=%{rule.msg}',setvar:tx.sql_injection_score=+%{tx.critical_anomaly_score},setvar:tx.anomaly_score=+%{tx.critical_anomaly_score},setvar:tx.%{rule.id}-WEB_ATTACK/SQL_INJECTION-%{matched_var_name}=%{tx.0}"


Using variables in regex
Well, how do I use the content of a variable in regex?

$username = "user1"
file {  "userdata.tar.bz2":
                source => "puppet://$server/modules/$module/
userdata.tar.bz2",
                ensure => $users ? {
                                /$username/ => absent,
                                default => present,
                        },
}

$users is a custom fact that contains all local users:

users => at avahi bin daemon dnsmasq ftp games haldaemon lp mail
messagebus nobody ntp polkituser postfix pulse root sshd suse uuidd
wwwrun man news uucp puppet user1

When I hardcode "user1" into the regex my test works fine and the file
is removed.

But things like /$variable/ or /\$variable/ or /#{variable}/ just
don't work.
Is it even possible in version 0.25.4?





Issues with Node Regex

I am trying to match groups of nodes - i.e.

Node: synd1-path2.path2.some.domain
Node: synd2-path2.path2.some.domain

By using either of the node definitions below:

node /^synd\w+\.path2\.some\.domain$/ {
    include ibapps
    include db
}


Using Regex in Embedded Pig in Java
All,

 

I am using pig embedded in Java and need to use matches in my pig job.
However when I try to use escape characters in the pig line, the
compiler complains. How do I use complex regex while embedding?

 

Sample code that is throwing errors:

 

myServer.registerQuery("filtered = FILTER firstcut BY dIP matches
'\Q34.21.12.*\E';");

 

error: invalid escape sequence.

 

Thanks,

 

Matt



A question about android regex implementation
Hi  Jesse and All,
I have written some simple benchmarks for harmony regex and find the
performance of harmony is poor compared to RI. For example, Mathcer.find()
only reach 60% of that of RI. I heard Android use icu4jni re-implement
this
module. Since icu4jni use native code I think it may has higher
performance
than harmony. I am trying to use icu4jni as the back-end of harmony regex
but find icu4jni has no functions related to regex operations.
I know there are some android guys in our community. So can anyone tell me
some detail info for android's regex, like if it re-implement the regex
logic using native code by android itself rather than icu4jni and really
get
higher performance compared to harmony regex? Thanks a lot!


client-side password validation using regex
Hi all,

I was wondering if it's possible to validate a <html:password> field
on client-side by using a regular expression.
A look at validateMask.js told me that the only field types supported are
'hidden', 'text', 'textarea' and 'file'.

Code:

            if ((field.type == 'hidden' ||
                field.type == 'text' ||
                 field.type == 'textarea' ||
                                 field.type == 'file') &&
                 (field.value.length > 0)) {

                if (!jcv_matchPattern(field.value, oMasked[x][2]("mask")))
{
                    if (i == 0) {
                        focusField = field;
                    }
                    fields[i++] = oMasked[x][1];
                    isValid = false;
                }
            }


Is this the exspected behavior? Is there any reason for not supporting
'password' fields?
If so, how would I validate a password field by using a regex (without
changing the js file on my own :))?

Cheers,


Ref. 324 * Geoinformationszentrum
Tel. 0211 9449-6310 * Fax: 0211 9449-6610
Email: stephan.### @it.nrw.de<mailto:stephan.k### @it.nrw.de>



Created: (HIVE-1483) Update AWS S3 log format deserializer regex
Update AWS S3 log format deserializer regex