Powerbuilder - Trying to importString a long string with a single double quote (") - powerbuilder

importstring(ls_string)
The string is a tab delimited text that has a single quote. This single quote is causing an error when the string is imported into the DataWindow.
I tried to replace all occurrences of double quote with ~"or \" but both do not work.
What do you think is a potential work around?
Thanks.

The datawindow escape character for a single quote (') is three tilde characters and then the single quote (which escapes the single quote as well as the tilde itself).
This makes the entry [O'Connor] look like [O~~~'Connor].
In the PB help this is under the heading: 'Nested strings and special characters for DataWindow object properties'

Related

Double Quotes in ASCII

What is the ASCII number for the double quote? (")
Also, is there a link to a list anywhere?
Finally, how do you enter it in the C family (esp. C#)
The ASCII code for the quotation mark is 34.
(Well, strictly speaking it's not a real quotation mark but the inches mark that we commonly use as quotation mark. A real quotation mark is a typographical character that is not available in ASCII.)
There are plenty of ASCII tables on the web. Note that some describe the standard 7-bit ASCII code, while others describe various 8-bit extensions that are super-sets of ASCII.
To put quotation marks in a string, you escape it using a backslash:
string msg = "Let's just call it a \"duck\" and be done with it.";
To put a quotation mark in a character literal, you don't need to escape it:
char quotationMark = '"';
Note: Strings and characters in C# are not ASCII, they are Unicode. As Unicode is a superset of ASCII the codes are still usable though. You would need a Unicode character table to look up some characters, but an ASCII table works fine for the most common characters.
It's 34. And you can find a list on Wikipedia.
Try Google and you will get tons of ASCII tables.
here is another alternative: http://www.wolframalpha.com/input/?i=%22
you are never going to need only 1 quote, right?
so I declare a CHAR variable i.e
char DoubleQuote;
then drop in a double quote
Convert.ToChar(34);
so use the variable DoubleQuote where you need it
works in SQL to generate dynamic SQL but there you need
DECLARE #SingleQuote CHAR(1)
and
SET #SingleQuote=CHAR(39)
yes, the answer the 34
In order to find the ascii value for special character and other alpha character I'm writing here small vbscript. In a note pad, write the below script save as abc.vbs(any name with extention .vbs) double click on the file to execute and you can see double quotes for 34.
For i=0 to 150
msgbox i&"="&char(i)
next

C++ - When escaping a double quote it appends the backlash too

Why is appending the backslash too?
If I dont use the backslash for escaping the doble quote, the compiler obviously complains, but if I try to escape the double quote it appends the backslash too.
Am I wrong using the \" in a string?
As noted by king_nak:
This is just the debugger's view. The string doesn't contain the backslash.
The debugger tries to display the string in C++ format, not in text format. The idea is, you can copy what the debugger shows to you, paste it into a C++ program, and it will work as expected. If the debugger didn't escape the quotes, it would generate a syntax error.
So everything is OK, you are using the escape character correctly.

RegEx for Find and Replace not escaped apostrophes in Android Studio IDE

I'm trying to make a RegEx to find and replace all non escaped apostrophes in Android Studio.
So far I've came up with this:
[^\][']
This will select an apostrophe and the char to the left of it, if it's not a backslash (i.e. if it is not escaped already!).
The problem is that if I have a word " d'effectuer " it will put the cursor on " d' ", but I don't want to replace the letter to the left of the apostrophe. It should find the same words but the selection should be only on the apostrophe itself so I can then replace it with " \' ". Could this be done somehow?
Note: I also tried doing this in Notepad++
with >'\< and then replacing with \' and it doesn't work for some reason. The find actually works correctly but when I hit the replace button it doesn't replace anything...
Try enclosing the substring that you want to keep within parentheses to form a capturing group:
([^\])[']
Then you can reference it using $1 when doing the replacement, e.g. replace it with $1replacement where replacement is whatever will replace the apostrophe.
Without RegEX- We can directly remove ' symbol.
String data ="d'effectuer";
String a=data.trim().replace("'","");
The regex [^\w ] will match anything that is not alphanumeric or space. So you can use the [^\w] for Replace apostrophe .
I faced this same issue. I found that the easiest thing to do is
Find all the escaped characters (\') and replace them the not escaped version (') - gets you to having no correctly escaped characters
Find those not escaped characters (') and replace them with the escaped version (\') - now you can escape all characters at once
Simple workaround for a task you don't want to devote a lot of time to

Find in Sublime Text 2: how to make sublime text search for double quotes when I use find with quote and vise versa

I have a JavaScrip document that is very long. I need to find strings that come before or after specific pattern, but I don't know if author of document used single quote (') or double quote (") for strings. So I have to repeat my search every time.
Can I make Sublime Text ignore double or single quote and search for all matching patterns?
Turn on Regular Expressions with Alt+R, then type the following into the search field:
["'](String To Find)["']
The brackets surrounding your String To Find will allow you to reference the matched string with \1

CSV parsing for embedded double quotes

I've written a simple CSV file parser. But after looking at the wiki page on CSV formats I noticed some "extensions" to the basic format. Specifically embedded comma via double quotes. I've managed to parse those, however there is a second issue: embedded double quotes.
Example:
12345,"ABC, ""IJK"" XYZ" -> [1234] and [ABC, "IJK" XYZ]
I can't seem to find the correct way to distinguish between an enclosed double quote and none. So my question is what is the correct way/algorithm to parse CVS formats such as the one above?
The way I normally think about this is basically to look at the quoted value as a single, unquoted value or a sequence of double quoted values that form a value joined by quotes. That is,
to parse the next atom in the row:
read up to the first non whitespace character
if the current character is not a quote:
mark the current spot
read up to the next comma or newline
return the text between the mark and the character before the comma (strip spaces if appropriate)
if the current character is a quote:
create an empty string buffer
while the current character is not a quote
mark the current position +1 (skip the quote character)
read up to the next quote
if the buffer is not empty, append a quote to it
append to the buffer the text between the mark and the character before the current position (to strip both quotes)
advance one character (past the just read quote)
read up to the next comma or newline
return the buffer
essentially, split each double quoted segment of the quoted string and then catenate them together with quotes. thus: "ABC, ""IJK"" XYZ" becomes ABC, , IJK, XYZ, which in turn becomes ABC, "IJK" XYZ
I would do this using a single character look-ahead, so if you're scanning the string and find a double quote, look at the next character to see if it is also a double quote. If it is, then the pair represents a single doublequote character in the output. If it's any other character, you're looking at the end of the quoted string (and hopefully that next character is a comma!). Be sure to account for the end-of-line condition when looking at the next character, too.
If you find a double-quote, then you should look for a double-quote in the end of the word/string. If you can't find, then there is an error. The same for a quote.
I suggest you try Flex/Bison in order to write a parser for the CSV file. Both tools will help you to generate a parser and then you can use the C files with the parser and call it from your C++ program.
On Flex, you create a scanner that can find your tokens, like "word" or ""word"". On Bison, you define the syntax.
A double double-quote ("") is a literal double-quote, while a lone double-quote (") is used for enclosing text (including commas).
Here's a regex for a csv field, if that makes things easier:
([^",\n][^,\n]*)|"((?:[^"]|"")+)"
Group 1 will contain the field if it isn't in quotes, group 2 will contain the field if it is in quotes, minus the surrounding quotes. In that case, just replace all instances of "" with ".
I suggest reading: Stop Rolling Your Own CSV Parser and this CSV RFC. The first is really just someone who wants you to use their C# CSV parser, but still explains many issues.
Your parser should be examining a character at a time. I used a double bool strategy for my parser in D. Each quote toggles weather the string is quoted or not. When in a quoted Cell you flag when hit a quote, and turn off quoting. If the next character is a quote, quoting is turned on, a quote is added to the result and the flag is turned off. If the next character isn't a quote then the flag is turned off and so is quoting.

Resources