Coldfusion - How can I remove a '#' character from a file name - coldfusion

I'm running into a problem when trying to upload certain files. If a file has a '#' in the name, I get errors when trying to then open the file. Is there a way to strip the '#' character from the filename before uploading it?
I've tried using Replace, but it throws an error when I use '#' in there:
<cfset myfile = #Replace('myfile', '#', '', 'all')#>
I could use createUUID, but there may be multiple file types, so I don't necessarily know what the file extension will be.

When you upload the file, use reReplace() to remove any non alpha numeric characters in the final name of the file. You might also consider replacing spaces with underscores and/or making the name all lowercase letters.

Related

How to make multiple lines become a single line in BigQuery?

I have a database that has a field containing cells with multiple lines like in the picture below
Instead of separated by an 'enter'/new line, I'd like them to be combined as one line so that I can export them to CSV without any problem.
I've tried using REPLACE(rejection_reason, '\n', '') but it gives me the same output.
Is there any workaround on this?
Thank you
Hmm, REPLACE(rejection_reason, '\n', '') should work well. However, it might be related to Windows-like line separator - \r\n. I would suggest you to try:
REGEXP_REPLACE(rejection_reason, '[\n\r]', '')

Get an error when trying to import a CSV using Google Bigquery CLI with backslash as an escape character

When trying to upload a csv file to BigQuery with the following params:
bq load --quote='"' --null_marker='\\N' --source_format=CSV sendpulse.user_orders gs://data-sendpulse/user_orders_3.csv
I get an error when trying to parse the following row:
"0","63800.00","1","0","Service \"Startup Pack\""
Obviously, Bigquery doesn't treat backslash as an escape character for inner quotes, but is there a way to specify backslash as an escape character?
Tried different options and always got errors.
Update:
Quote in a quoted csv value is escaped with another quote and there is no setting for an escape character.
I don't see a better workaround than replacing all \" with ' or "" in your files.

Searching for a Regex to disable any "/" before the first letter

I am actually got an Angular form which upload some files on a cloud, but those files could be in directories with subdirectories like
"directory/subdirectory/filename"
My form had some inputs, and I added a ng-pattern on a text input.
I can't accept sentence with "/" at first character like
/directory/subdirectory/filename
I am searching for a regex to deny any "/" until the first letter of a directory name.
So, correct way is:
directory/blabla;
and wrong way is:
/directory/blabla;
I tried [^/]* but it is detect all the '/' in my sentence.
Any idea please ?
This should do: ^[^\/]\S+$
The regex checks that the first character is not a '/', and then accepts every non-whitespace character till the end.
Demo

VBscript regular expression

There is a txt file containing multiple lines with - Browser("something").page("something_else").webEdit("some").
I need to retrieve the names of the browser, page and fields (names surrounded by double quotes ) and replace the line with "something_somethingelse_some" (concatinating the names of the browser, page n filed respectively), please help.
the names can be anything so we should go with regex. Note we have to convert everything comes in the above format within the text file till the EOF..
You may try this:
^Browser\("(.*?)"\).page\("(.*?)"\).webEdit\("(.*?)"\).*$
and replace by:
$1_$2_$3
Regex Demo

Wrap JSON field names in quotes using vim search and replace

I have a simple json file that isn't well formatted it looks like:
{ ID: '092558667',
NAME: 'Store Made',
PARENT_CATEGORY_ID: '692558669',
INCLUDED_IN_NET_SALES: '1' }
All I need to do is wrap the field names in double quotes. In vim the closest I have gotten is to wrap the field name and the colon in quotes - obviously I need to figure out how to get the string without the colon wrapped. Here's what I am trying:
:%s/[A-Z_]*:/"&"
If I leave the colon out of the query the whole file ends up being selected.
You can use capture groups:
%s/\([A-Z_]*\):/"\1":/
To handle already quoted keys properly:
%s/"\?\([A-Z_]*\)"\?:/"\1":/
Ok, with the information above I ended up with this:
:%s/[ \t]\([A-Za-z_].*\):/"\1":/
it supports upper- and lowercase chars
it skips already quoted fields
Since this can be considered a completion, I mapped it to a vim completion shortcut ctrl-x ctrl-j in .vimrc (they all start with ctrl-x ) :
:noremap <C-x><C-j> :%s/[ \t]\([A-Za-z_].*\):/"\1":/<CR>