String Question [message #172796] |
Wed, 02 March 2011 20:38  |
Patrick[1]
Messages: 2 Registered: March 2011
Karma: 0
|
Junior Member |
|
|
Don't usually frequent this news group, but I have a stumper. At least
it is stumping me.
I have one variable that I have assigned a string value to;
(verbatum from my code)
$errval = 'ERROR: duplicate key violates unique constraint
"machines2_pkey"';
and another variable that I assign a value from a command;
$pglerr = pg_last_error();
The value being: ERROR: duplicate key violates unique constraint
"machines2_pkey"
yet when I do a strlen $errval is 64 and $pglerr is 65.
What am I missing here? I've tried trim() on the latter and still get 65.
If someone could shine some light on this for me I would appreciate it.
Thanks
--
Patrick A. Smith Assistant System Administrator
Ocean Circulation Group – USF - College of Marine Science
http://ocgweb.marine.usf.edu
The trouble with doing something right the first time is that nobody
appreciates how difficult it was. - La Rochefoucauld
|
|
|
|
|
|
|
|
Re: String Question [message #172807 is a reply to message #172801] |
Thu, 03 March 2011 07:32   |
Curtis Dyer
Messages: 34 Registered: January 2011
Karma: 0
|
Member |
|
|
Denis McMahon <denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com> wrote:
> On 02/03/11 21:14, Patrick wrote:
>> On 3/2/2011 3:59 PM, Denis McMahon wrote:
>>> On 02/03/11 20:38, Patrick wrote:
<snip>
>> Thanks. I came to that same conclusion and found that there are
>> 2 spaces between "ERROR:" and "duplicate" in the second string
>> and only one in the first. No way you could ever tell that from
>> the output on the screen.
>
> Ah, you were viewing the error message in a browser and then
> pasting it into text? Browsers do things like 's/\s*/ /'
Did you mean:
s/\s+/ /
Your regex would replace "foo" with " f o o ".
--
Curtis Dyer
<?$x='<?$x=%c%s%c;printf($x,39,$x,39);?>';printf($x,39,$x,39);?>
|
|
|
|
Re: String Question [message #172814 is a reply to message #172813] |
Thu, 03 March 2011 19:17  |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Denis McMahon wrote:
> On 03/03/11 07:32, Curtis Dyer wrote:
>> Denis McMahon <denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com> wrote:
>>
>>> On 02/03/11 21:14, Patrick wrote:
>>>> On 3/2/2011 3:59 PM, Denis McMahon wrote:
>>>> > On 02/03/11 20:38, Patrick wrote:
>> <snip>
>>
>>>> Thanks. I came to that same conclusion and found that there are
>>>> 2 spaces between "ERROR:" and "duplicate" in the second string
>>>> and only one in the first. No way you could ever tell that from
>>>> the output on the screen.
>>> Ah, you were viewing the error message in a browser and then
>>> pasting it into text? Browsers do things like 's/\s*/ /'
>> Did you mean:
>>
>> s/\s+/ /
>>
>> Your regex would replace "foo" with " f o o ".
>
> Probably. I should wake up before posting regexes heh.
>
Another reason why I would prefer to learn Linear B, than Regexps. It
tends to be slightly easier.
> Rgds
>
> Denis McMahon
|
|
|