Apache Camel Route - RegEx for multiple HTTP Request - http

Here is a sample to route message if USER_AUDIT Transaction with http request list:
http://www.blabla.com/dothis/USER_AUDIT?AA=aa&BB=bb
<when>
<simple>${in.header.CamelHttpPath} regex '(?i)/USER_AUDIT'</simple>
<bean ref="transactionList" method="get" />
<bean ref="transactionTransform" method="convert" />
</when>
Now I want to route other transactions see, CARD_VER to the same route.
Is there a syntax like:
<simple>${in.header.CamelHttpPath} regex '(?i)/USER_AUDIT' || '(?i)/CARD_VER'</simple> ?

In the regular expression you can add "or"s so you can match if either of the 2 is matching. But then you need to a bit a bit reg exp ninja to do that. That would be something alike
'(?i)/[USER_AUDIT|CARD_VER]'
But check the JavaDoc for regular expression: http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html. And Other docs for how to do regular expressions. Also there is plugins you can install in your Java editors where you can try out regular expressions on the fly, to figure out a pattern that works for you.
However in the Simple expression in Camel you can also use binary operators, and add a 2nd expression. So it would be something like:
<simple>${in.header.CamelHttpPath} regex '(?i)/USER_AUDIT' ||
${in.header.CamelHttpPath} regex '(?i)/CARD_VER'</simple>
In Camel 2.8.x or older, you could only have 1 binary operator, but from Camel 2.9 onwards you can have as many you want.
See details in the Camel documentation for the Simple expression. See the section about operators at: http://camel.apache.org/simple

Related

How to properly write Regex validation in Firestore Security Rules

I'm trying to validate submitted data against Regex expressions in Firestore Security Rules. I've read through the documentation, but I'm still unsure how to write them.
I read through the Regex documentation here https://firebase.google.com/docs/reference/security/database/regex , but it doesn't really show how to use it in Firestore. I tried using an 'allow validate' rule and copy/pasted a regex expression from the docs, but I'm getting all kinds of errors.
Here's what I tried:
Do I need to put it in a format like this? (From the docs) allow create: if !("ranking" in request.resource.data)? If so, how do I use a regex expression with it?
It looks like you're trying to start a regex with /. That's not going to work - it's not like perl. Slash starts a path object. Might want to check the API documentation on this. You should just be passing a plain string to matches() that contains the regex to match.
https://firebase.google.com/docs/reference/rules/rules.String#matches

URL Rewrite in IIS7 Regular expression Pattern

I want a URL pattern for the following where :
this
http://www.test.com/xyz_number.jpg?vin=xyz&date=31052012
will be redirected to :
http://www.test.com/xyz/31052012/xyz_number.jpg
NOTE: Here xyz_number and date value are dynamic which will be changing for each request.
The following regular expression will perform the match:
^http://www.test.com/([^.]*).jpg\?vin=([^&]*)&date=(\d*)$
And the following expression will do the replacement:
http://www.test.com/$2/$3/$1.jpg
You don't say whether you're doing this in an ASP.NET HTTP Handler, or in an IIS module, but hopefully, this will give you a start.

Regular Expression for percents (with % sign) in ASP.Net RegEx Validator

I need a regex for the ASP.Net (4) Regex Validation control. It needs to be a RegEx validator to support other dynamic behaviors outside the scope of this post..
I was using the following, but it fails if the user enters the % sign following the number (which is a req of my spec):
^(100(?:\.0{1,2})?|0*?\.\d{1,2}|\d{1,2}(?:\.\d{1,2})?)$
I tried adding an atomic group of ^(?>%?) at the end, with no luck, after reading the excellent post
Regular expression greedy match not working as expected
Does anyone have any ideas?
Try this
^(100(?:.0{1,2})?%?|0*?.\d{1,2}%?|\d{1,2}(?:.\d{1,2})?%?)$
try this one instead:
^0*(100(\.00?)?|[0-9]?[0-9](\.[0-9][0-9]?)?)%?$

Pattern matching using decorators

I want to define a specific URL pattern using Sitemesh decorators.xml. I want to define a decorator that matches all URLs ending with "/story/_NUMBER_" to be targetted by the decorator. I tried:
<decorator name="customMain" page="customMain.jsp">
<pattern>/story/[0-9]+</pattern>
</decorator>
But this does not work.. Do regular expressions work in decorators.xml? If not, how do I target URLs that end with the above pattern?
Just ran into this myself. I don't think it's possible to use regular expressions at all. Only wildcard patterns with * and ?.
Look at the source here for more details.

String Functions in IIS Url Rewrite Module

The IIS URL Rewrite Module ships with 3 built-in functions:
* ToLower - returns the input string converted to lower case.
* UrlEncode - returns the input string converted to URL-encoded format. This function can be used if the substitution URL in rewrite rule contains special characters (for example non-ASCII or URI-unsafe characters).
* UrlDecode - decodes the URL-encoded input string. This function can be used to decode a condition input before matching it against a pattern.
The functions can be invoked by using the following syntax:
{function_name:any_string}
The question is: can this list be extended by introducing a Replace function that's available for changing values within a rewrite rule action or condition?
Another way to frame the question: is there any way to do a global replace on a URL coming in using this module?
It seems that you're limited to using regular expressions and back-references to construct strings - i.e. there's no search/replace mechanism to replace every instance of X with Y in {REQUEST_URI}, without knowing how many instances there are.
I've had a quick glance at the extensibility introduced in the 2.0 RTW and don't see any 'light' means of introducing this.
Looks like you have to implement your own provider as shown here:
http://learn.iis.net/page.aspx/804/developing-a-custom-rewrite-provider-for-url-rewrite-module/

Resources