In ActionScript, what character does "\t" represent? - actionscript

In ActionScript, what character does "\t" represent? I can see it in some ActionScript And was wondering what character it really was.

It's a "tab space". \n and \r are other special characters that, in AS, represent new line characters (drops text down to next line, as if you were pressing the "enter" key in a text editor).
See http://www.adobe.com/livedocs/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=textcontrols_060_05.html for more.

Related

printing backslash AND unicode characters in one field

let's say I want to print a backslash and the pound symbol on a label: \£
I cant. I can only print either the backslash or the pound symbol, but the other one will render incorrectly.
This will print correctly the pound symbol, but will print a cent symbol instead of the backslash:
^XA
^CI28
^FO^AT^FH^FD_c2_a3^FS
^XZ
And this will print correctly the backslash, but not the pound symbol:
^XA
^CI13
^FO^AT^FH^FD_c2_a3^FS
^XZ
Do you know a way to combine these two in one single field ?
Thanks
Use the Field Hex feature:
^XA
^FO10,10^A0,40,40^FH_^FDEuro Symbol/_15/^FS
^XZ
As per ZPL script documents, they mentioned "You can mix character sets on a label." using ^CI command.
But there is no example scripts are available to mix character sets, Instead of that the example scripts are just explaining "how to remap the characters".
Also the document has clearly mentioned that If you want to print backslash, you should use ^CI13(^CI13 must be selected to print a backslash (\)). But If we use ^CI13, Latin characters are not printing properly which expects ^CI28.
So I'm not sure if it's possible to print both Latin characters and backslash (\) in same label.

How to delete non text characters, new line, tab, etc, from params of JSON string

I have JSON strings that may contain \n, \t, which I don't want to save into database. strip_tags helps only with simple strings. I am using gsub(/(\\n)|(\\t)/, "").
I wonder if there is another Rails helper method or a better way to achieve this.
e.g
"[{\"type\":\"checkbox-group\",\"label\":\"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nFill in\\nthe Gap (Please\\nfill in the blank box with correct wor\",\"name\":\"checkbox-group-1527245153706\",\"values\":[{\"label\":\"Option 1\",\"value\":\"option-1\",\"selected\":true}]},{\"type\":\"text\",\"label\":\"\\n\\t\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\tWhat are the unique features of\\ne-commerce, digital markets, and\\ndigital goods? \\n\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\n\\t\\t\",\"className\":\"form-control\",\"name\":\"text-1527245426509\",\"subtype\":\"text\"}]"
You can make use of squish or squish!
" Some text \n\n and a tab \t\t with new line \n\n ".squish
#=> "Some text and a tab with new line"
Squish removes all the whitespace chars on both ends and grouping remaining whitespace chars (\n, \t, space) in one space
I think this one may help you,
JSON.parse(string).map{ |a| a['label'] = a['label'].squish; a}

Rails 5 - regex - for string not found [duplicate]

I have following regex handy to match all the lines containing console.log() or alert() function in any javascript file opened in the editor supporting PCRE.
^.*\b(console\.log|alert)\b.*$
But I encounter many files containing window.alert() lines for alerting important messages, I don't want to remove/replace them.
So the question how to regex-match (single line regex without need to run frequently) all the lines containing console.log() and alert() but not containing word window. Also how to escape round brackets(parenthesis) which are unescapable by \, to make them part of string literal ?
I tried following regex but in vain:
^.*\b(console\.log|alert)((?!window).)*\b.*$
You should use a negative lookhead, like this:
^(?!.*window\.).*\b(console\.log|alert)\b.*$
The negative lookhead will assert that it is impossible to match if the string window. is present.
Regex Demo
As for the parenthesis, you can escape them with backslashes, but because you have a word boundary character, it will not match if you put the escaped parenthesis, because they are not word characters.
The metacharacter \b is an anchor like the caret and the dollar sign.
It matches at a position that is called a "word boundary". This match
is zero-length.
There are three different positions that qualify as word boundaries:
Before the first character in the string, if the first character is a
word character.
After the last character in the string, if the last
character is a word character.
Between two characters in the string,
where one is a word character and the other is not a word character.

Design patterns on removing escaped characters iOS

Taking json from a website and getting some json results back with escaped characters.
What's the best design pattern for removing the characters we don't like?
Here are some we don't like from here:
\b Backspace (ascii code 08)
\f Form feed (ascii code 0C)
\n New line
\r Carriage return
\t Tab
\v Vertical tab
\' Apostrophe or single quote
\" Double quote
\ Backslash character
But my question is, in general, should you do
it before you save it?
after you save it, convert it right away?
or should you convert it right before you display/use it?
Remove it right after downloading. It's kinda costly (especially if you use regular expressions), so it'll be done once, and not needed again.

How to remove all spaces from a variable which do not appear next to a particular symbol?

I need to remove the spaces between words in a variable, but never remove any of the spaces which are next to any of these symbols: ①, ②, ③, ④, ⑤, ⑥, ⑦, ⑧, ⑨, or ⑩. E.g.:
The bear ate the fish.
This becomes:
Thebearatethefish.
E.g.:
The ① bear ate the ② fish.
This becomes:
The ① bearatethe ② fish.
How can I remove all of the spaces from a variable, except for those spaces which appear next to one of those symbols?
Normally what you would want to do is do a pattern replace:
string.gsub("The bear ate the fish.", "%s", "")
Now you need to teach gsub about the special characters:
string.gsub("The ① bear ate the fish.", "[^①②③④⑤⑥⑦⑧⑨⑩]%s[^①②③④⑤⑥⑦⑧⑨⑩]", "")
This will substitute any whitespace as long as the previous and next character is not in the set. If don't have Lua compiled with unicode, you might need to substitute the characters with the proper unicode values.

Resources