capture keyboard character as string - mfc

Under PreTranslateMessage() check the keydown event and capture the same in some variable,
Keydown event capture the value for single character only,
But I would like to capture certain no of character and search the same string inside list control
I am able to search a single character, but for multiple character, need some way to capture the same such as I can create the search string such as xyz and can search the same in list control , but as soon as I press x, it is getting searched.
Please suggest the approach to solve the same.

Related

What are "steps" in RegexBuddy?

RegexBuddy on the tab "Debug" shows how regular expressions are executed step by step. But what exactly that steps mean? What operations are behind every step?
The steps count is basically how many times the current position in the input was changed, which is a very good indicator of performance.
The "current position" may be at any character or between characters (including before and after the entire input).
Simplifying it, regex engines process the input by moving the current position along the input and evaluating whether the regex matches at that position. They also keep track of the position in the regex the match is up to.
I don't want to turn this answer into a regex tutorial, but... regex engines always consume as much of the input as possible while still matching. To give a simple example, given the input "12345" and the regex .*1.*, the regex engine will first apply .* consuming all input leaving the position at the end of the input, fail to match a 1, then back track by "uncomsuming" one character at a time until it finds a 1, then continue. You can see that this would take 9 steps just to process the initial .*.
By contrast, if the regex was [^1]*1.*, the regex will match the "1" in just one step.
In RegexBuddy's debugger, a step is when the regex engine matches something, or fails to match something. Steps that match a character are indicated by all the characters matched by the regex so far which will usually be one character more than the previous step. Steps that match a position, like a word boundary, are indicated by the characters matched so far plus "ok". Steps that failed to match something are indicated by the characters matched so far plus "backtrack".
If you click on any of the matched characters in the debugger, RegexBuddy selects the token in the regular expression that matched those characters and highlights all the characters in the debugger matched by that token. If you click on an "ok" or "backtrack" indicator, RegexBuddy selects the token in the regex that matched or failed to match.
Moving the cursor with the keyboard has the same effect as clicking. Pressing the End key on the keyboard moves the cursor to the end of a step. Then pressing Arrow Up or Down moves the cursor to the previous or next step while keeping the cursor at the end of that step. By moving the cursor this way, you can easily follow how the regex engine steps through your regular expression and which characters is matches and backtracks along the way.
For more details, see these two pages in RegexBuddy's help file:
https://www.regexbuddy.com/manual.html#debug
https://www.regexbuddy.com/manual.html#benchmark

Vim remove character from position

How can I remove one character from some position ? For example, I have string hello, remove third char and get helo.
I have tried to use next expression, but it doesn't work.
.s/\%3c//g
The \%c special atom is a zero-width match; i.e. it adds a restriction (on the byte count of the match) without consuming the character. To do this, append another atom that consumes it, e.g. . for any character match. Then, your substitution will work as expected:
.s/\%3c.//g
In normal mode also known as command mode but not to confuse with command-line mode, you can type:
03lx
0 to go to the start of the line.
3l to move 3 characters forward.
x to remove the character under the cursor.

How to specify to match more than one character inside regex sqaure brackets?

Given a user input string, I need to find if it end with one of the following - .com, .net , .edu., html etc.
Is there any way to do this with the regex square brackets?
I tried $[.com|.net|.html] and $[(.com)(.net)(.html)] but both don't work.
You want to use a capture group.
(\.com|\.net|\.html)
This will match either one of the values. You can add additional values by appending another pipe inside the parenthesis and placing the new value after the pipe.
You could try this:
\.com$|\.net$|\.edu$
or
(\.com|\.net|\.edu)$

Replace all characters in a regex match with the same character in Vim

I have a regex to replace a certain pattern with a certain string, where the string is built dynamically by repeating a certain character as many times as there are characters in the match.
For example, say I have the following substitution command:
%s/hello/-----/g
However, I would like to do something like this instead:
%s/hello/-{5}/g
where the non-existing notation -{5} would stand for the dash character repeated five times.
Is there a way to do this?
Ultimately, I'd like to achieve something like this:
%s/(hello)*/-{\=strlen(\0)}/g
which would replace any instance of a string of only hellos with the string consisting of the dash character repeated the number of times equal to the length of the matched string.
%s/\v(hello)*/\=repeat('-',strlen(submatch(0)))/g
As an alternative to using the :substitute command (the usage of
which is already covered in #Peter’s answer), I can suggest automating
the editing commands for performing the replacement by means of
a self-referring macro.
A straightforward way of overwriting occurrences of the search pattern
with a certain character by hand would the following sequence of
Normal-mode commands.
Search for the start of the next occurrence.
/\(hello\)\+
Select matching text till the end.
v//e
Replace selected text.
r-
Repeat from step 1.
Thus, to automate this routine, one can run the command
:let[#/,#s]=['\(hello\)\+',"//\rv//e\rr-#s"]
and execute the contents of that s register starting from the
beginning of the buffer (or anther appropriate location) by
gg#s

Using Regex in Word to Mass Modify Entries

How can I find the expression '([anumber][anumber],' in word?
I have [0-9][0-9], but this is repeated a few times per option therefore it removes everything in the pattern. How do i either dictate either to remove **(**[0-9][0-9], with that left parentheses or only remove [0-9][0-9], for the first instance of it in each line?
Let's clarify your problem first:
You have something like (0123, (4567, etc., and
you want to make them (23, (67, respectively.
In the replace dialog,
put ([(])[0-9][0-9] in the find box, and
put \1 in the replace with box.
Actually, put ( in the replace with box is just fine, but \1 is a more flexible option.