How do I run the same piece of code for multiple text inputs without using select case? - asp.net

I have eight aspx text inputs labelled txtBoookingId1, txtBookingId2 etc etc. I have a sub which handles eight buttons clicks as the code is more or less the same for each. I have it so it knows which one is pressed. I want to run "booking = System.Text.RegularExpressions.Regex.Replace(txtBookingId2.Text.Trim, "[^0-9.]", "")" to trim off any letters but I want the txtBokingId2 part to be the correct one based on which button was clicked.
Is there an easier way of doing this than using a Select with eight cases and the same line of code in each with only the bolded above changed slightly? I tried having a string "Dim txt As String = "txtBookingId" & btnPressed.ToString" (which would give txtBookingId1, txtBookingId2 etc based on button then using that in place of txtBookingId2 but it's not valid code as there isn't an text input named "txt".
Code decides which button is clicked based on where CommandArgument=1,2,3 in the text input etc

Related

Adobe Illustrator text selection different from other document

I am doing a copy-paste job from Word to Illustrator, whenever I double click on the word in the docx the whole word is selected like this
but when I try to double click in illustrator it leaves the first point out and selects the last "/" or selects the whole word but not just the middle part.
what could be the reason for that, and is there an easier way to do that
For simplest cases you can modify the selected range this way:
var sel = app.selection; // get the selection
sel.start += 1; // remove first letter from the range
sel.end -= 1; // remove last letter from the range
sel.select(); // select the new range
app.copy(); // copy selected text in clipboard
You can put the script into an action and assign some keyboard shortcut for the action.

Cells in Jupyter notebooks

I am trying to parse a pdf using PyPDF2 in a Jupyter notebook. Below is how I would like to write the different parts of the code, that is, the extract text statements in one cell and the RegEx in a new cell. However, if I separate the two pieces of code as below, the RegEx only runs through the last page of the file and not through the whole file (12 pages). Why does this happen? I would really like to use different cells.
import PyPDF2
import re
file = open(r'file.pdf', 'rb')
doc = PyPDF2.PdfFileReader(file)
#print(doc.getNumPages())
#new cell
for i in range(0, 12):
page = doc.getPage(i)
text = page.extractText()
#print(text)
#new cell
doc_re = re.compile(r'S\d+_\d+', re.IGNORECASE)
result = doc_re.findall(text)
print(result)
Each time you run your for loop, you're resetting the value of text by using text = page.extractText()
The RegEx is running on what you give it, which is text. Even though your loop runs over 12 pages, the second cell of code receives the final value of text (which is whatever you assign it to be on the last iteration of the loop).
You can either move the code from your second cell inside of your for loop, or a better option would be to add each page's text to text.
So, turning text = into text += should solve your problem.

How do I advance to the next occurrence of a variable in R Studio IDE

When I highlight any string of text in the R Studio console a rectangle is drawn around all other occurrences of this same string of text. How do I advance to the next occurrence of this arbitrary string of text? I'd like the keyboard shortcut.
CTRL-F3 is the closest shortcut I know. This takes the selected string of text, drops it into the Find dialog and jumps to the next occurrence (keep pressing CTRL-F3 to cycle through)
If you would like to move to the next occurrence of a word/variable and select it while also keeping the original selected, this command exists but does not have a default shortcut assigned to it.
The command is called 'Find and add next' (or 'Quick Add Next' in older versions). You can assign a shortcut to it by going into Preferences -> Code -> Modify_Keyboard_Shortcuts. I use Alt+Cmd+Right (on a Mac) as that is an unassigned key binding.
You can see bellow I have used the command twice to select three of the four instances.
On a Mac, I use command+f to call Find with a selected string and then use control+g to move onto the next match.
This needs to be over 30 characters, but only needs 2:
F3

How to customize the look of currently selected(highlighted) completion in zsh?

Main question
I would like to add powerline characters at the start and at the end of the selected completion, like this:
Started the completion menu by inserting c and pressing the TAB key.
Moved right in the completion menu by pressing the right arrow key.
Moved down in the completion menu by pressing the down arrow key.
Is there any way to make zsh look/behave like in the pictures?
Note
Added powerline triangle + blank character at the beginning and blank character + powerline triangle at the end should somehow be accounted when columns are created to keep the alignment correct.
Bonus
Add 2 blanks at the beginning of every completion in the list, so that when the completion is selected it doesn't look like the text was moved to the right.
( This issue can be seen by comparing the completion with and without the selection. )
Alternative question
In case that previously explained behavior is impossible to get without changing the zsh source code, is it at least possible to add powerline triangle only at the end of the selected completion?
My unsuccessful attempts
I have tried using the lc, rc, and ec variables in the list-colors style but that didn't help:
Completion list was badly aligned and it created all kinds of visual problems.
Symbols were inserted in all elements of the completion list, not just the selected one.
I have also tried using the ma variable, but I couldn't properly insert a character at the beginning:
The variable expects only a number that represents a color and it is probably wrapped in some escape sequences, so the output did not look as expected.
This works for me.
zstyle ":completion:*:default" list-colors ${(s.:.)LS_COLORS} "ma=48;5;153;1"
Uses my LS_COLORS and then ma sets the background of my selection to bold and color 153 from https://jonasjacek.github.io/colors/.
Found from https://www.zsh.org/mla/users/2010/msg00811.html

Ask: Replace multiple new line into single new line or br

I have problem with replace character.
If I have one textbox, and I write into textbox with many new line.
and the results I wanted a lot of new lines replaced with one or two new lines such as comments in the facebook.
I'l try this code :
litText.Text = System.Text.RegularExpressions.Regex.Replace(Text1.Text, "[\\r\\n]+", "<br /><br />", System.Text.RegularExpressions.RegexOptions.Multiline);
this works if I press a lot of button enter,but this isn't works if I press button enter once then displays new line twice. I want if I press once or two button enter, fixed display once or two new line. except three times or more than two.
please your assistance and your opinions.
Thank you
You want to duplicate the entire \r\n multiple times, as opposed to just duplicating one of them like in your example. Also you should use #"..." for this.
litText.Text = System.Text.RegularExpressions.Regex.Replace(
Text1.Text, #"(\r\n|\r|\n)+", "<br>",
System.Text.RegularExpressions.RegexOptions.Multiline);

Resources