Scratch equals operator problems - mit-scratch

I am using scratch.mit.edu version 2.0 on the internet and writing a program to evaluate a postfix expression. As I iterate through the input string such as: "23+" (postfix) letter by letter using the letter..of...block, it works fine.
I then add a letter.. of.. block to identify a spacebar character so the user can insert blanks in the expression eg "2 3 +"
However, there seems no way to recognize a blank character. I tried
1) Lookahead = ""
2) Lookahead =' '
3) Lookahead =''
None of which pick up that a space has been encountered.
Here is the project: https://scratch.mit.edu/projects/77653712/

In Scratch, the box is the string literal - no quotes, unless you're looking for literal quotes. Just put a space in the box.
Just set it to check <(Lookahead) = [ ]>: (brackets are the symbol for the box)
(That black line is me pressing ctrl+a to highlight and show that it exists.)

OK, I have found the solution. There is no character to represent a blank. You simply press space bar once!
You can see the letter nextChar of blanks is an empty space but, you must add space using the spacebar for it to work!!

Related

Is there a way to select everything right of first string in line

So I got a body of space separated text and I'm trying to mine names. These names are the first :
Tsuru Stork greeting for a long last life. Unisex
Yama Mountain; Restrainer; Unisex
Yuka A bright Star Unisex
Yumi A beautiful archery bow Unisex
Yuna The archer Unisex
How can I select everything right of the first string in each row?
I figured out how to select the names themselves with this:
(\n+)[A-Z]{1}\w+
But there doesn't seem to be an easy way in word to highlight, copy then paste the selection.
In summary, how do I select elements after the first string in a new line?
If this is done in Microsoft Word then try the following:
*^13
This stands for:
- A space character.
* - Match any sequence of characters.
^13 - Match a newline character (ASCII 13).
If I understood your question correctly, this will highlight all text to the right of the first word in each line. See the below screenshot (don't mind the Dutch pls.):
If you actually need to make sure you select everything after the first multiple space seperation, then maybe use {3,4}*^13:
Again, don't mind the Dutch along with the locale parameter delimiter (semi-colon) in the occurence indicator. This will be a comma if your locale is English.
You can use regex like : (^\w+)
^ start of line
\w+ matches world char one or many times
Demo

How to add a small straight line (I mean like this: a̅ b̅ X̅) onto a character inside a string?

I want to add small straight line onto some desired characters/numbers inside a string inside textview. I couldn't find a solution. Maybe using NSMutableAttributedString. Meanwhile, I mean doing this programmatically. There is strikethrough style, but not overstrike style. Or maybe adding the letters "a" and "_" with different .baseline values. But how to add both characters onto each other then?
Is it possible?
EDIT: Due to make a try for the helpful answers below, I think to make the line at a spesific height is needed. "A\u{0305}" makes the up line very close to the character, as if it sticks. Is there a way to make it at specific height? For example, if we assume that all the keyboard-inputted characters are written inside every single boxes, the ceiling side of these boxes could be lined?
So this (note: see edit below) appears to be an "a tilde ogonek" (it's Lithuanian).
You can write it for instance as follows using these two Unicode characters:
let atildeogonek = "\u{0105}\u{0303}"
let title = "How to add a small straight line (I mean like this: \(atildeogonek)) onto a character inside a string?"
The first character is the a with an ogonek, the second one is the tilde.
EDIT: The initial question specifically asked about the character ą̃ ("a tilde ogonek") in the title, and I used this code to demonstrate how to use Unicode characters in a Swift string. After posting this answer, the question was edited to be more general about "a line above a character".
Programmatically, you could use a function like this:
func overline(character: Character) -> Character? {
return "\(character)\u{0305}".first
}
That will take a character as input and return a new character (glyph) that has had the Unicode combining overline character added to it. It will return nil if adding the combining overline character fails.
The code print(overline(character:"A")!), for example, returns "A̅"
Or, if you want to add an overline to every character in a string, you could use a function like this:
func overline(characters: String) -> [Character?] {
return Array(characters).map { return "\($0)\u{0305}".first
}
}
(I'm not sure if there are any characters for which the above will fail, so I'm not sure if force-unwrapping the result is safe. Thus I left the result of both functions to be optional Character/Array of Character.)
You can easily find the unicodes of ā or ą̃ by using the xcode's own Character Viewer. Just follow the following steps :
hit : Control + Command + SpaceBar
If you get a compact one like this, click the upper right corner icon to expand it.
When expanded, Click the settings gear in the corner . Select customize list.
select Enclosed Characters
Go down to the bottom and open Code tables then add Unicode.
Now, just search for your required Character and you can check its unicode value. here i am searching ā
to print unicode's value :
print("\u{0101}")

Notepad++ newline in regex

Suppose you have this file:
x
a
b
c
x
x
a
b
c
x
x
and you want to find the sequence abc (and select the whole 3 lines) with Notepad++ . How to express the newline in regex, please?
Notepad++ can do that comfortably, you don't even need regexes
In the find dialogue box look in the bottom left and switch your search mode to Extended which allows \n etc.
As odds on you're working on a file in windows format you'll be looking for \r\n (carriage return, newline)
a\r\nb\r\nc
Will find the pattern over three lines
Update 18th June 2012
With the new Notepad++ v6, you can indeed search for newlines with regexes. So you can just use
a\r\nb\r\nc
even with regular expressions to accomplish what you want. Note \r\n is Windows encoding of line-breaks. In Unix files, its just \n.
Unfortunately, you can't do that in Notepad++ when using regex search. Notepad++ is based on the Scintilla editor component, which doesn't handle newlines in regex.
You can use extended search for newline searching, but I don't think that will help you search for 3 lines.
More info here.
Update: Robb and StartClass0830 were right about extended search. It does work, but not when using regular expressions search.
^a\x0D\x0Ab\x0D\x0Ac
This will work \x0D is newline and \x0A is carriage return. Assumption is that each line in your file ends with ascii 10 and 13.
I found a workaround for this.
Simply, in Extended mode replace all \r\n to a string that didn't exist in the rest of the document eg. ,,,newline,,, (watch out for special regexp chars like $, &, and *).
Then switch to Regexp mode, do some replacements (now newline is ,,,newline,,,).
Next, switch to Extended mode again and replace all ,,,newline,,, to \r\n.
For Notepad 6 and beyond, do this as a regular expression:
Select Search Mode > Regular expression (w/o . matches newline)
And in the Find what Textbox : a[\r\n]b[\r\n]+c[\r\n]
or if you are looking at the (Windows or Unix) file to see its line breaks as \r\n or \n then you may find it easier to use Extended Mode:
Select Search Mode > Extended (\n, \r, \t, \0, \x...)
And in the Find what Textbox for Windows: a\r\nb\r\nc\r\n
Or in the Find what Textbox for Unix: a\nb\nc\n
Wasn't clear if the OP intent is to select the trailing line return (after the 'c') as well, as would be necessary to remove the lines.
To not select the trailing line return, as appropriate for replacing with a non-empty string, simply remove the final line return from the matching statement.
Note that if there should be a match on the last line of the string, without a matching trailing line return, the match fails.
a\r\nb\r\nc works for me, but not ^a\x0D\x0Ab\x0D\x0Ac
Hmm, too bad that newline is not working with regular expressions. Now I have to go back to Textpad again. :(
Select Search Mode Which is
Extended (\n, \r, \t, \0, \x...)
\n is new line and such
This is Manuel
Find: "(^a.$)\r\n(b.)\r\n^(c.*)$" - pickup 3 whole lines, only storing data
Replace with: "\1\2\3" - Put down (replay) data
Works fine in Regex with Notepad++ v7.9.5
Place holders: ^ Start and $ End of line can be inside or out of ()store as shown, though clearly not necessary in given example. Note "[^x]" is different - here "^" is "NOT".
Advantage of storing and replay allows much more complicated pattern match without having to type in again what you want to end up with, and even change of replay: "\2\3\1" for "bca"
I have run accross this little issue when the document is windows CR/LF
If you click the box for . to match newlines you need .. to match CR/LF so if you have
<blah><blah>",
"<more><blah>
you need to use ",.." to match some string comma cr/lf another string
In Notepad++ you can also try highlighting the desired part of the text and then pressing CTRL+J.
That would justify the text and thus removing all line endings.

How to search for carriage return in eclipse

If I have the following text in my Eclipse editor:
Text Line 1
Text Line 2
I would like to concatenate the text into:
Text Line 1Text Line 2
My first idea was to search for carriage return character '\n' and replace it with '' to concatenate it.
I tried using the search function of Eclipse, but it does not recognize carriage return character.
Are there any other editor that can do this?
Eclipse does this if you:
turn on regular expression mode in search/replace
enter \R for the newline
Just use Edit -> Find/Replace, switch on the Regular Expressions checkbox, search for \n and replace it by space.
I tried it in Eclipse 3.4 and it worked well.
Short answer:
I decided to use \s++ as separator in multi-line search expressions (with regular expressions enabled) and \Qfoo\E to escape special characters if required.
Long answer:
As soru already answered, for any "Unicode linebreak sequence" a regular expression search with \R can be used.
A pure carriage return is represented by \r. Upper and lower case make a difference. \R represents any unicode linebreak sequence (for example \r\n).
I found this SO question because I wanted to search for a multi-line expression in Eclipse, including line breaks and tabs:
#Override
#Transient
In order to include the white spaces in my regular search expression I used (on Windows platform)
#Override\r\n\t*#Transient
Following expressions also work:
#Override\R\t*#Transient
#Override\s++#Transient
Please note that the second expression also matches #Override #Transient
without a line break, which is fine for me.
Following expressions did not! work for me:
#Override\r\t*#Transient
#Override\n\t*#Transient
Explanation of some regular expressions:
\R represents any unicode linebreak sequence (for example \r\n)
\s represents any white space
\t represents a tab
* matches zero or more occurrences
++ matches one ore more occurrences
\Q and \E escape wrapped content. Use them if your original multi line expression includes special regex characters, for example
\Q/**\E\s++\Q*\E
matches
/**
*
Also see:
Difference between \n and \r?
https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Most find and replace tasks in editors (at least, TextPad) have the ability to replace via a regex. If you can find this option in eclipse, then just use that.
\r is the correct regular expression for carriage return. But Eclipse standard editor does not find it.
So use external editor, for example notepad++

Is there anyway to have vim not count special characters as words?

I'm using VIM do alot of work for me using the macros.
There's alot of text in columns and I want the macro to move between columns effortlessly by pressing the w key to "move to the beginning of the next word"
For example:
DataSourceName string ""
DetailFields []string
DynamicControlBorder boolean empty may be void
EscapeProcessing boolean True
FetchDirection long 1000
FetchSize long 12
Filter string ""
GroupBy string ""
HavingClause string ""
However when I do this, VIM only does this for letters; whenever it encounters a "[" or a " it interprets this as another word, messing up the macro because it now appears that there is an additional column.
Is there any setting I can change to make vim ignore the special characters and treat them just like the letters by skipping over them?
[Update]
I found an even better answer to this question over at superuser.com:
https://superuser.com/questions/12679/is-there-anyway-to-have-vim-not-count-special-characters-as-words/12828#12828
You could make the special characters a part of word, see the iskeyword option. In your case you could simply try the following commands:
:set iskeyword+=[
:set iskeyword+=]
The W command (Shift+W) moves to the next word delimited only by spaces, not whatever Vim is configured to consider a "word" (as unshifted w does).