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.
Related
Originally I have urls like www.astral.com/user/1. I was able to convert it to www.astral.com/casuername by patterns match using [user:cas] where casuername comes from [user:cas]
However, I also have www.astral.com/user/1/publications which I want to convert to www.astral.com/user/1/publications to www.astral.com/casuername/publications.
Is there any way to achieve what I want?
Thanks.
After some search, I found that, my objective can be achieved using subpath auto module obtained from https://www.drupal.org/project/subpathauto
Use pathauto module
https://www.drupal.org/project/pathauto
Create the pattern for the urls
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
I am using RegularExpressionValidator control with
[http(s)?://]*([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
regular expression to validate Url. I need to allow german characters
(ä,Ä,É,é,ö,Ö,ü,Ü,ß)
in Url. What should be exact regular expression to allow these characters?
I hope you are aware that it is not easy to use regex for URL validation, because there are many valid variations of URLs. See for example this question.
First your regex has several flaws (this is only after a quick check, maybe not complete)
See here for online check on Regexr
It does not match
http://RegExr.com?2rjl6]
Why do you allow only \w and - after the first dot?
but it does match
hhhhhhppth??????ht://stackoverflow.com
You define a character group at the beginning [http(s)?://] what means match any of the characters inside (You probaly want (?:http(s)?://) and ? after wards instead of *.
To answer your question:
Create a character group with those letters and put it where you want to allow it.
[äÄÉéöÖüÜß]
Use it like this
(?:https?://)?([äÄÉéöÖüÜß\w-]+\.)+[äÄÉéöÖüÜß\w-]+(/[-äÄÉéöÖüÜß\w ./?%&=]*)?
Other hints
The - inside of a character group has to be at the start or the end or needs to be escaped.
(s)? is s?
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]?)?)%?$
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/