WinPhone7 pass values with special character between pages - windows-phone-7

I am going to pass string value between pages.
The value contains "&" character.
Since the values are split using "&", so the value is chopped.
How can I escape this special character?

use URL encoding...
for ex: if you want '&' .. use '& amp;' (no spaces)
Recommended way is to use
Uri.EscapeUriString(stringToEscape)
method which does this for you.
Documentation at
http://msdn.microsoft.com/en-us/library/system.uri.escapeuristring%28v=VS.95%29.aspx

Related

How do I "regex-quote" a string in XPath

I have an XSL template that takes 2 parameters (text and separator) and calls tokenize($text, $separator).
The problem is, the separator is supposed to be a regex. I have no idea what I get passed as separator string.
In Java I would call Pattern.quote(separator) to get a pattern that matches the exact string, no matter what weird characters it might contain, but I could not find anything like that in XPath.
I could iterate through the string and escape any character that I recognize as a special character with regard to regex.
I could build an iteration with substring-before and do the tokenize that way.
I was wondering if there is an easier, more straightforward way?
You could escape your separator tokens using the XPath replace function to find any character that requires escaping, and precede each occurrence with a \. Then you could pass such an escaped token to the XPath tokenize function.
Alternatively you could just implement your own tokenize stylesheet function, and use the substring-before and substring-after functions to extract substrings, and recursion to process the full string.

How to use escaped colon in thymeleaf th:text?

This is what happens when I try to use a colon in th:text:
and a backslash doesn't seem to fix it:
How can I use the colon symbol in th:text?
If you want to place a literal into th:text, you have to use single quotes: th:text="'7:00AM'". See documentation here.
(By contrast, something like this th:text="7_00AM" is valid - because it is a literal token. Such strings can only use a subset of characters, but do not need enclosing 's.)

Need a regular expression to allow only one character in a text box in asp.net

I need a a regular expression to allow only one character for a textbox. Actually i want to validate a text filed to enter a single charecter for Initial (for name)
In a regular expression, '.' (dot) matches a single character.
If you want to be sure that this single character is alphabetic, use:
[a-zA-Z]
or in a posix system: [:alpha:]
Now, to know exactly how to implement it, we need to know in which language your code is written.
For a starter, have a look to
http://en.wikipedia.org/wiki/Regular_expression
You can set the textbox property MaxLength to 1 and use a regex to validade if a letter.

Remove special characters from a string in JSTL

I have a string in jstl: 'Tall &. Big'
But I want this to replace with :'TallBig'.
I am trying to this by using fn:replace(String,'&',''); but I don't know how to mention multiple characters in this function to be removed.
Means I want to remove all special characters from a string.

Another way instead of escaping regex patterns?

Usually when my regex patterns look like this:
http://www.microsoft.com/
Then i have to escape it like this:
string.match(/http:\/\/www\.microsoft\.com\//)
Is there another way instead of escaping it like that?
I want to be able to just use it like this http://www.microsoft.com, cause I don't want to escape all the special characters in all my patterns.
Regexp.new(Regexp.quote('http://www.microsoft.com/'))
Regexp.quote simply escapes any characters that have special regexp meaning; it takes and returns a string. Note that . is also special. After quoting, you can append to the regexp as needed before passing to the constructor. A simple example:
Regexp.new(Regexp.quote('http://www.microsoft.com/') + '(.*)')
This adds a capturing group for the rest of the path.
You can also use arbitrary delimiters in Ruby for regular expressions by using %r and defining a character before the regular expression, for example:
%r!http://www.microsoft.com/!
Regexp.quote or Regexp.escape can be used to automatically escape things for you:
https://ruby-doc.org/core/Regexp.html#method-c-escape
The result can be passed to Regexp.new to create a Regexp object, and then you can call the object's .match method and pass it the string to match against (the opposite order from string.match(/regex/)).
You can simply use single quotes for escaping.
string.match('http://www.microsoft.com/')
you can also use %q{} if you need single quotes in the text itself. If you need to have variables extrapolated inside the string, then use %Q{}. That's equivalent to double quotes ".
If the string contains regex expressions (eg: .*?()[]^$) that you want extrapolated, use // or %r{}
For convenience I just define
def regexcape(s)
Regexp.new(Regexp.escape(s))
end

Resources