逃避标点符号和引号 [英] Escaping punctuations and quotes

查看:101
本文介绍了逃避标点符号和引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VB新手。我有一个访问数据库,其数据使用单引号,如(不)或(g''night)。


我创建了一个可以进行搜索和替换的程序,我认为应该只是搜索('')并将其替换为(&"''" &),但这只会导致插入十亿(&)。好吧也许它不是那么多但是它很多。


难道没有更简单的方法来绕过数据使用在代码中产生错误的字符。我在这个网站上看到了一个Perl的例子,但是我不知道怎么把它翻译成VB。


非常感谢geek in training

Hi I am new to VB. I have an access database that has data that uses the single quote like in (don''t) or (g''night).

I have create a procedure that will do a search and replace, Which I thought should be simply search for ('') and replace it with (& "''" &), but that just leads to a billion (& "''" &) of these being inserted. Okay maybe it''s not that much but it is a lot.

Isn''t there an easier way to get around "data" that uses characters that produce errors in "code". I saw an example in Perl on this site but I don''t get it how to translate that into VB.

many thanks from the "geek in training"

推荐答案

我不太关注。你喜欢做什么样的转换?
I don''t quite follow. What sort of conversion would you like to do?



我不太关注。您希望做什么样的转换?
I don''t quite follow. What sort of conversion would you like to do?



当我运行当前脚本时,一个记录中有一个包含单引号的字段。我收到一个错误。我假设VB期待和匹配单qoute。我猜,我的问题基本上是如何封装违规字符或者我可以为可防止错误的违规字符做什么样的替换。


当我进行插入时,错误发生,并且违规值看起来像这样(b''ad cha''ract''er)。但通常它只是一个''。


我不想更改用户输入的数据。我希望他们按照他们得到的方式或拼写单词的方式输入数据。我只是不想像M''duqes这样的词语给我一个错误,因为没有匹配的单引号。


所以没有转变。更像是嗯...变色...... ..... masqurading .....可能是字符欺骗? ;-)


现在我的工作是用'替换''。后者是左上角#1键旁边的东西,但是当我开始改变数据以适应代码而不是编写代码以适应数据时,我认为我走错了路。不是这样???

When I run the current script and one record has a field that has a single quote in it . I get an error. I am assuming the VB is expecting and matching single qoute. My question basically, I guess, is how do encapsulate the offending character OR what kind of substitution can I do for the offending character that will prevent the error.

The error occurs when I am doing an insert and the offending value looks something like this ( b''ad cha''ract''er). But usually it is just one '' .

I don''t want to change the data the user is entering. I want them to enter the data the way they get it or the way the word is spelled. I just don''t want words like M''duqes to give me an error cause there is no matching single quote .

so no transformation. more like hmmm...... chameleoning..... masqurading ..... character deception possibly ?? ;-)

right now my work around is to substitute '' with `. The later is whatever that thing is next to the #1 key in the upper left hand corner, but I think I am going down the wrong road when I start altering the data to fit the code instead of writing the code to fit the data. Not so???


嗯...好吧,我最近读过一些关于能够用#而不是'来分隔SQL中字符串的内容。也许这会有所帮助。我认为你可能会在Access论坛中找到更多帮助。


实际上,他们的提示和技巧中有一个条目包含撇号。也许它会有所帮助。您可以在他们的T& T索引中找到它,此处。只需使用浏览器的文本搜索功能(当然还有您自己的眼睛)来扫描报价。
Hm... well, I did read something recently about being able to delimit strings in SQL with # instead of ''. Perhaps that would help. You''ll probably find more help for this in the Access forum, I think.

Actually, there is an entry in their tips and tricks covering apostrophes. Perhaps it will help. You can find it in their T&T index, here. Just use the text-search function of your browser (or your own eyes, of course) to scan for "Quotes".


这篇关于逃避标点符号和引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆