I'm completely new to Xtext so thanks in advance for your help.
I have the following:
terminal PATTERN_SRC : STRING '.png';
Pattern: name='pattern:' value=PATTERN_SRC;
I want the user to code it like this:
pattern: (URL to image ending with .png / .jpg / .gif)
Currently I'm checking it like this but this does not work.
Is there a nice way to solve this? Thanks in advance!
Sone remarks:
Don't use the feature name. This is a reserved keyword for calculating unique names of an element in a resource.
STRING is like this: "Sometext".
So what you want is "somefile.png"
What you described is "somefile".png
You could just use STRING and implement a validation rule to ensure your URL is valid.
Related
URL is something like
/home/rawstring13245/rawstring534533453
I want the rule that saves only 13245 to parameter and 534533454 to another but ignore raw strings before them.
how to achieve it in route.config file?
i want this because strings are not parameters , I need only parameters out of string
like:
url:"{controller}/rawstring{action}/rawstring{id}",
what to enter in place of raw string? I don't need those strings. and yeah each raw string is of same length= 10
You can get complete variables as strings and get your desired part by using the sub-string method. Its the quickest solution, i thought it solve your problem.
I need some regex or maybe native Rails trick to check if user entered only domain (without "http", "https", "www" and so on.
So, this one would be valid:
google.com.ua
And this would be invalid:
https://www.google.com.ua
Maybe, it can be simplified just to check if string contains only dots and take it like valid one, and if it contains any other characters - block it.
Tell me please what is better to use for such case and what would be regex for it or another decision.
Thanks.
^(?!www\.)[a-zA-Z0-9.-]+$
Try this.See demo.
https://regex101.com/r/wZ0iA3/5
I'm trying to build an Href using Razor
The string is going to end up looking like this:
https://www.notmysite/controller/action?order_ID=xxxxxxx&hashComparator=iFxp3%2BszAMaEB%2FnHCtRr9Ulhv0DumtyDumCik4gKypJqi0BdOGXXsr9QDkfefAsLaR1Xy%2BrX9VcuzP1pF2k6dL%2F92UxphzTKqNAZP2SSZGWtvyO5az%2F9JvDY%2Bsq5TBQo7%2FYAAMIU4QxiSX1SBKk8SUNECW3ZmKM%3D
In my model I have the order id and the hash string
As the route is not a part of my site I don't believe I can use the default methods like #Url.Action
and therefore can't use protocol: Request.Url.Scheme
like I've used elsewhere.
So at present I'm trying to figure out how to create this using string functions
I've tried
Url.Encode
Url.EscapeDataString
Html.Encode
but am getting no where fast:
Click Here to be transferred
The output text always has plusses and equals in them and doesn't work.
Which combination do I need?!
I've figured out a way of doing it:
#{
var url = string.Format(
"https://www.notmysite.co.uk/controller/action?order_ID={0}&hashComparator={1}",
#Uri.EscapeDataString(Model.bookingNumber.ToString()),
#Uri.EscapeDataString(Model.hashCode));
}
<p>Click Here to be transferred</p>
Edit 2015 - As mentioned by Jerads post - The solution is to only encode the query string elements and not the whole URL - which is what the above does.
This was the first link that came up for this issue for me. The answers didn't work for me though because I am using core, I think. So wanted to add this in.
System.Net.WebUtility.UrlEncode(MyVariableName)
If Url.Encode doesn't work try the above. Also as stated before don't use this on the entire URL string, just use it for the individual querystring variables. Otherwise there is a good chance your URL wont work.
The problem is that you're trying to encode the whole URL. The only pieces you want to encode are the querystring values, and you can just use Url.Encode() for this.
You don't want to encode the address, the querystring params, or the ? and & delimiters, otherwise you'll end up with an address the browser can't parse.
Ultimately, it would look something like this:
Click Here to be transferred
The easier method is to use #Html.Raw(Model.SomethingUrl)
I'm currently re-working an application and want to add in a version number to the application URL paths. For example:
http://mydomain/app/VERSION-ID/resource/...
My question is, what is the correct or standard format to add a version id to a URL string? Is there any disadvantage to just having it numeric (1.1 or 1-1):
Example: https://api.twitter.com/1.1/account/verify_credentials.json
Or is it better to have a non numeric identifier to be more intuitive as the url is public facing?
Thanks.
Do not use dots in a URL unless you're defining domain spaces. Use either dashes or other truncated versions (that don't use disallowed characters in the URL).
EXAMPLE:
Example: https://api.twitter.com/v1-1/account/verify_credentials.json
UPDATE: Here is some more information in another thread. My preference is not to use dots if at all possible, but it is apparently OK to do.
Can urls contain dots in the path part?
I have a string that may have a path to a file. Example src="/folder/whatever". How do I replace that path with src="http://www.sitename.com/folder/whatever ?
If your string contains src="/...", possibly many times, do this:
string.gsub!(/\bsrc="(\/[^"]*)"/, 'src="http://www.sitename.com\1"')
If your string contains the URL only, do this:
src.replace('http://www.sitename.com' + src)
More information about String#gsub and String#gsub! here: http://www.ruby-doc.org/core/classes/String.html#M000832
route helpers. use url instead of path.
i like pts's solution, but i might remove the slash from the regex...so it would be:
string.gsub!(/\bsrc="([^"]*)"/, 'src="replacement_text\1"')
use the \1 to access the back reference