Sublime select a word shorcut with all signs - sublimetext2

There is a shortcut
Ctrl + D Select word - Repeat select others occurrences
but in the case of
'11.20'
or
'SELECT#ME'
the shortcut will only select ether first "SELECT" or the second part "ME"
Is there a way to create a shortcut to select a whole word and only break it by ether single or double quotes or a space
so in my example it will select '11.20' and 'SELECT#ME'
Thank you

You can set which characters are considered word separators by editing the word_separators setting in your User Preferences. The default value is:
"word_separators": "./\\()\"'-:,.;<>~!##$%^&*|+=[]{}`~?"
Add the entire thing to your preferences (Preferences -> Settings-User on Windows/Linux or Sublime Text -> Preferences -> Settings-User on OS X), remove the characters you want to be included as part of words (# and ., in your case), save the file, and you should be all set. Please note that the \ characters in front of the \ and " items are escaping them, so if you want to remove \, for example, you'll need to remove both back slashes.

Related

How To use MYSQL Select Query to find an Apostrophe followed by an Uppercase letter, made from a typo (typographic) error

I needed an MySQL Query to find all rows which contained a text pattern like
It'S hot
(an apostrophe followed by an uppercase letter), made by mistake (a typo), when the typist held the shift key too long while typing fast.
SELECT artist, title
FROM songs
WHERE BINARY title REGEXP '^.*\'[A-Z]+'
BINARY forces case sensitivity,
^ starts at beginning of data field,
.* matches any character(s)
\\' escapes a single quote
[A-Z] matches uppercase A thru Z
\+ matches anything after it, even nothing i.e. end of line

How to prevent entering text containing spaces in mySQL

It happens occasionally that users erroneously enter text with a trailing space in a text column, which is hard to spot visually. This can later cause problems when this text field has to be matched against another where the trailing space is not present. Is it possible in mySQL to enforce that a text string cannot contain a certain character (space in this case)?
Thankful for feedback!
There are a number of ways to achieve what you want:
Check the user input in your application and reject it if it contains a space. If your primary worry is the quality of the user inputs, then this is probably the best way to do this.
You can remove spaces (or just starting / trailing spaces) from the user input either in the application logic or using sql.
If you opt for removing all spaces from the user input in sql, then use the replace() function. If you just want to remove the starting and trailing spaces, then use the trim() function to achieve the desired results.
Using mysql function a simple way is based on trim()
select
trim(' try with trim ')
, length (trim(' try with trim '))
, length (' try with trim ')
from dual ;

How to delete all data of a json document except the key/value I want

So I have a rather big document with entries like:
"kff126d":"Infinity"
And others like:
"kff126d":"0.03702955"
And a few dozens of other keys like kff126e and so on, and I would like to remove everything that isn't the one key I want to keep, and whatever value is inside the second set of quotation marks, so I can take a look at abnormal values.
Could someone help me out? I've tried looking arround but it's quite complex compared to the few things I've done with regex before this. Thanks in advance.
I can suggest the following regex:
("kff126d":"[^"]*")|(?:(?!"kff126d":).)+
with . matches newline option ON, and replace with $1\n.
See the regex demo
This will insert redundant empty lines that you can remove with Edit > Line Operations > Remove Empty Lines.
The point is to match and capture with (...) the part that you need to keep, and remove all the rest. All the rest can be matched with a tempered greedy token (?:(?!"kff126d":).)+ (matches any character (with .) that does not start the "kff126d": sequence).
V
And here is the screen of the replacement result with your updated sample data:
Press ctrl+h and in the find section use : (?m)^(?!"kff126d":).*?$ and leave the replace section blank. Select the search mode 'Regular Expression' and select Replace All.
This will transform
"kff126d":"0.12345"
sdfgsdfg
sgsfgsfg
"kff126d":"0.03702955"
"kff126d":"0.03702955"
rererer
"kff126d":"0.03702955"
sfdgsfgfsg
sdfgsfg
"kff126e":"0.8888888888888"
into
"kff126d":"0.12345"
"kff126d":"0.03702955"
"kff126d":"0.03702955"
"kff126d":"0.03702955"
Afterwards, if you want to remove all the blank lines, you can replace \R+ with \n
Description
Using Notepad++:
find all characters that is not the desired key name
which are also not the value Infinity
work with json strings which are not neatly padded, aka compressed json
leave behind a vertical column of values
The Regex
Find What:
.*?(?:"kff126e":"((?!Infinity)[^"]*)"|\Z)
Replace with:
$1\n
How To
From Notepad++
press the ctrlh to enter the find and replace
mode
Select the Regular Expression option
Select the ". matches newline" option
In the "Find what" field place the following regex
.*?(?:"kff126e":"((?!Infinity)[^"]*)"|\Z)
In the Replace with field enter $1\n Click Replace All
Goto pub for favorite beverage.
Explanation
NODE EXPLANATION
----------------------------------------------------------------------
.*? any character (0 or more times (matching
the least amount possible))
----------------------------------------------------------------------
(?: group, but do not capture:
----------------------------------------------------------------------
"kff126e":" '"kff126e":"'
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
(?! look ahead to see if there is not:
----------------------------------------------------------------------
Infinity 'Infinity'
----------------------------------------------------------------------
) end of look-ahead
----------------------------------------------------------------------
[^"]* any character except: '"' (0 or more
times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
" '"'
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
\Z before an optional \n, and the end of
the string
----------------------------------------------------------------------
) end of grouping
What's happening
The desired value will be placed into capture group 1 aka $1, which will replace the matched text. The \n inserts a return character. The regex engine will continue parsing your text after the last replace operation until it reaches the end of the file.

what does it mean when "> is returned on command line? [duplicate]

I'm new to sql and for some reason, the arrow symbol ( -> ) that I am used to seeing in teh command line, which mean it is ready for input, is now displayed as ( '> ) and it does not accept commands. What does it mean and how do I get back to ( -> ) ?
Thanks
It means that it is treating any input which follows as part of a string literal, until it encounters a(n unescaped) string termination quote ' character.
This will have happened because you previously began the string literal with such a string termination quote character. For example:
mysql> SELECT foo
-> FROM tbl
-> WHERE bar LIKE 'somestring
'> this is still part of somestring'
-> ;
find the attached image
use '/ command and press enter then it will go on next line starting with ->
then use ; and press enter.
it happens if there is unbalanced '(single quote) in query.
It means you have an incomplete query. Most likely it's something related to a missing quotation, semi-colon at the end, or parentheses aren't closed.
You can exit the query with: '\c
Not sure what happens to the query but it gets you back to the mysql> prompt.
enter image description here
As you can see, I encountered the same issue, the solution is :
type '> in the command line, then insert some command as I did(please refer to the picture attached), and then the new line starts.

What does the ( ' > ) symbol mean in the command line in MySQL?

I'm new to sql and for some reason, the arrow symbol ( -> ) that I am used to seeing in teh command line, which mean it is ready for input, is now displayed as ( '> ) and it does not accept commands. What does it mean and how do I get back to ( -> ) ?
Thanks
It means that it is treating any input which follows as part of a string literal, until it encounters a(n unescaped) string termination quote ' character.
This will have happened because you previously began the string literal with such a string termination quote character. For example:
mysql> SELECT foo
-> FROM tbl
-> WHERE bar LIKE 'somestring
'> this is still part of somestring'
-> ;
find the attached image
use '/ command and press enter then it will go on next line starting with ->
then use ; and press enter.
it happens if there is unbalanced '(single quote) in query.
It means you have an incomplete query. Most likely it's something related to a missing quotation, semi-colon at the end, or parentheses aren't closed.
You can exit the query with: '\c
Not sure what happens to the query but it gets you back to the mysql> prompt.
enter image description here
As you can see, I encountered the same issue, the solution is :
type '> in the command line, then insert some command as I did(please refer to the picture attached), and then the new line starts.