VK_LEFT is not a character but VK_A is.
How can I differentiate them?
Thanks.
Not sure there is a really clean way to do this, but try looking at ToAscii or ToAsciiEx: if you get a 0 then it is a control character like VK_LEFT.
Related
something that could be like ${'c'?unicode} whould print 63 I went over the list of built-ins and didn't find anything like it.
There isn't, as of 2.3.27. It has come up for a few times, also the opposite of it (number to character), so maybe in 2.3.28. But, what's the use case?
When I add this to my vimrc:
set iskeyword-=#
It removes some syntax. I've only tested this in viml and ruby code. What's the reason for this? I've included images to show the effect in viml code.
EDIT: How would I go about removing it without affecting syntax? The reason why I removed it was to make it easier to select "$#" as a word. Anyone can offer a solution to this problem or an alternative way of doing that is greatly appreciated.
From 'isfname', which 'iskeyword' points to:
If the character is '#', all characters where isalpha() returns TRUE are included. … To include '#' itself use "#-#".
# (64) isn’t actually in the character set to begin with for me:
iskeyword=#,48-57,_,192-255
but if it somehow got in there for you, you can add a part starting with a caret to exclude it:
set iskeyword+=^#-#
Let's say I have something like:
Image.from_file("path/to_file/#{$variable_name}_[some_number].png")
I don't know what [some_number] will be, but I know that it will always be there.
How can I write a regex (presumably) so that it doesn't matter what [some_number] is?
Thanks.
--- edit ---
#DavidGrayson you're right. I don't need a regex at all (sorry for the wild goose chase folks).
Looks like I can get exactly what I need from newFileName = Dir.glob("#{variable_name}_*.png").first then Image.from_file("path/to_file/#{$newFileName}") etc.
Thanks to everyone who tried to help.
You can have variables in regexes in ruby: /#{$variable_name}_\d+\.png/
I am trying to grasp the concept of Regular Expressions but seem to be missing something.
I want to ensure that someone enters a string that ends with .wav in a field. Should be a pretty simple Regular Expression.
I've tried this...
[RegularExpression(#"$.wav")]
but seem to be incorrect. Any help is appreciated. Thanks!
$ is the anchor for the end of the string, so $.wav doesn't make any sense. You can't have any characters after the end of the string. Also, . has a special meaning for regex (it just means 'any character') so you need to escape it.
Try writing
\.wav$
If that doesn't work, try
.*\.wav$
(It depends on if the RegularExpression attribute wants to match the whole string, or just a part of it. .* means 'any character, 0 or more times')
Another thing you should consider is what to do with extra whitespace in the field. Users have a terrible habit of adding extra white space in inputs - its why various .Trim() functions are so important. Here, RegularExpressionAttribute might be evaluated before you can trim the input, so you might want to write this:
.*\.wav[\s]*$
The [\s]* section means 'any whitespace character (tabs, space, linebreak, etc) 0 or more times'.
You should read a tutorial on regex. It's not so hard to understand for simple problems like this. When I was learning I found this site pretty handy: http://www.regular-expressions.info/
I am trying to write a gsub for a regex match, but I imagine there's a more perfect way to do this .
My equation :
ref.gsub(ref.match(/settings(.*)/)[1], '')
So that I can take this settings/animals, and return just settings.
But what if settings is null? Than my [1] fails as expected.
So how can one write the above statement assuming that sometimes settings won't match ?
So that basically, if it finds the word, settings, than get rid of anything after it. But if it doesn't, no worries.
Thanks!
Why not do the simplest possible thing that could work?
ref.gsub(/(settings)(.*)/, '\1')