Insert a space in a string
I need to insert a space after every eight characters in a string.
For example:
< cfset mytoken = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD" >
< cfoutput >
< cfset replaceChar = "" >
< cfset mytoken = Insert (replaceChar, mytoken, 8) >
< cfset mytoken = Insert (replaceChar, mytoken, 17) >
< cfset mytoken = Insert (replaceChar, mytoken, 26) >
< cfset mytoken = Insert (replaceChar, mytoken, 35) >
< cfset mytoken = Insert (replaceChar, mytoken, 44) >
< cfset mytoken = Insert (replaceChar, mytoken, 53) >
< cfset mytoken = Insert (replaceChar, mytoken, 62) >
MyToken: #mytoken # < br / >
The above gives me results as
MyToken:ABCDEFGH QRSTUVWX YZABCDEF GHIJKLMN OPQRSTUV WXYZABCD IJKLMNOP
Can I get the same result by using a regular expression and reduce code?
Not quite, but almost. This:
reReplaceNoCase (mytoken, "([a-z][0-9]{1,8})", "\1", "all")
Means "a letter, followed by one to eight digits. You need:
reReplaceNoCase (mytoken, "([a-z |)") (0-9]_{1,8}) ', '\1', 'all')
That means one-to-eight letters or numbers. As Adam pointed out earlier, you can further simplify:
reReplaceNoCase (mytoken, "([a-z |)") (0-9]_{8}) ', '\1', 'all')
Tags: ColdFusion
Similar Questions
-
Hello
I'm trying to put spaces in the string after each 4 characters (2 bytes).
Any help will be greatly appreciated.
Thank you
hiNi.
Several ways to do so. My favorite is the regular expressions...
-
regular expression to exclude spaces in the string
Now that I'm that sleazy, I need help with a regular expression.
They must pass (or permutations it):
[00123]
[R012]
[r083]
These should fail (or permutations it):
[test]
[I was here]
[098 876]
Ooh [29873 eifvuh]]
I have most of it (the ' [' must be first; the '] "must be the last;) There must be some middle numbers, but I can't write an expression that will fail if there are 1 or more spaces in the string.
Thank you!
Tay
Several possibilities: try this regular expression.
^\[[a-za-Z]*[0-9]+[a-zA-Z0-9]*\]$
-
Insert variable in the text string
Hi, can someone help me insert variables in a text string? I use the "base series writing and Read.vi in labview.
I need to send the following string to the serial port:
Normal 0 false false false fr X-NONE X-NONE MicrosoftInternetExplorer4 / * Style Definitions * / table. MsoNormalTable {mso-style-name : « Table Normal » ; mso-tstyle-rowband-taille : 0 ; mso-tstyle-colband-taille : 0 ; mso-style-noshow:yes ; mso-style-priorité : 99 ; mso-style-qformat:yes ; mso-style-parent : » « ;" mso-rembourrage-alt : 0 cm 5.4pt cm 0 5.4pt ; mso-para-margin : 0 cm ; mso-para-marge-bottom : .0001pt ; mso-pagination : widow-orphelin ; police-taille : 11.0pt ; famille de police : « Calibri », « sans-serif » ; mso-ascii-font-family : Calibri ; mso-ascii-theme-font : minor-latin ; mso-fareast-font-family : « Times New Roman » ; mso-fareast-theme-font : minor-fareast ; mso-hansi-font-family : Calibri ; mso-hansi-theme-font : minor-latin ; mso-bidi-font-family : « Times New Roman » ; mso-bidi-theme-font : minor-bidi ;}
-$$ INPUT1SMSPHONE = numbers1, telephone2, phone3
-$$ INPUT1SMS_WSEC = 5
-$$ INPUT1SMS_DATAON = MESSAGE TYPE SMS HERE
How to do a vi with numbers1, telephone2 phone3 and TYPE SMS MESSAGE HERE as variables and send it to the serial port?
If someone could make an example vi that would be fantastic.
Kind regards
Mark
Thank you for your quick response. Your example is perfect thanks mate.
See you soon,.
Mark
-
Print every word in the new line for a space in a string
Hi all
I would print every word in the new line, if there is a space in the string.
Is there a better way using regexp?
declare
number of v_count;
v_text varchar2 (1000): = 'Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - Production | " ';
v_single_text varchar2 (1000);
number of v_space_pos;
Start
Select regexp_count (v_text,' ') in double v_count;
While v_count > 0
loop
v_space_pos: = instr (v_text,' ');
v_single_text: = substr(v_text,1,v_space_pos-1);
dbms_output.put_line (v_single_text);
v_text: = substr (v_text, v_space_pos + 1);
v_count: = v_count-1;
end loop;
end;
Thank you
Rambeau
HI - try as
with t as (select 'Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - Production' |) "" double str)
Select regexp_substr (str,'[^] +', 1, level)
t
connect by level<=regexp_count(str,'[^>=regexp_count(str,'[^>
-
Insertion of space between or moving along the timeline of the actions
Can someone tell me how to insert a space between stocks or move actions in the timeline panel. I'm new on board, although I have some previous experience with Flash.
I added a shortcut for it in the preferences.
Otherwise, you must go to
menu/timeline/insert time
-
Count the spaces in the string...
Hi, I use "PL/SQL Developer" program.
I need to count the number of spaces in the string...
Can someone help me with this...?
String, for example: 'One AsdA qwe' should return number = 2 - (2 spaces in this string)Raivis wrote:
Hi, I use "PL/SQL Developer" program.
I need to count the number of spaces in the string...
Can someone help me with this...?String, for example: 'One AsdA qwe' should return number = 2 - (2 spaces in this string)
This should do it.
LENGTH(
) - LENGTH(REPLACE( , ' ')) -
Error when CF reached a space in a string/text box
I seem to get an error whenever my code gets to a space in a string, any ideas whats up?
I work on an update form, you can have a look here:
http://Carus.ACEs.Shu.AC.UK/students/a8022782/staff-update1.cfm
And here is a list of members in the database, do what you like for them (a friend of mine all ready to), I don't care, just help me!
http://Carus.ACEs.Shu.AC.UK/students/a8022782/staff-members-all.cfm
Thanks in advance,
Andrew
Single quotes so that your database knows when to stop the strings and the following SQL command begins!
UPDATE Members SET first_name='#FORM.first_name#', last_name='#FORM.last_name#', address='#FORM.address#', town='#FORM.town#', postcode='#FORM.postcode#', phone_no='#FORM.phone_no#', password='#FORM.password#' WHERE member_id=#id# I'm actually a little surprised your database was not throw data incompatibility error type, it must be very forgiving on the syntax. Access by any chance?
P. S.
You would be really better to use best practices of
tags. UPDATE Members SET first_name= ... -
Substitute the inconsistent spacing with a single space in a string
is it possible to replace multiple spaces in a string with a space only. Number of places is different all the time.
say a field contains strings with spaces
I need to replace all those values so that there will be only one space between words.
For example.Input Expected Result aaa bbb aaa bbb ww vv ww vv ww ss kk ww ss kk [/code]
user11253970 wrote:
I'm in Oracle 9i :( I can't use reg expAssuming that the strings contain no CHR (0) (character with ascii code 0):
SQL> SELECT 'aaa bbb aaa bbb' str, 2 replace(replace(replace('aaa bbb aaa bbb',' ',' ' || CHR(0)),CHR(0) || ' '),CHR(0)) new_str 3 FROM dual 4 / STR NEW_STR ----------------------------------- ----------------------------------- aaa bbb aaa bbb aaa bbb aaa bbb SQL>
SY.
-
Insert a space character between each character in a string
I have an array of length variant. Each element of the array contains a string. I want to put a space character "" between each character of each string in the array. The length of the string in each element of the array varies.
I played with nested for loops with registers to lag and feedback without success and began to think that I do it's too difficult.
Thank you
Mike
(Lucither: your code will make any element of the array to an empty string.) It does not insert space between characters as needed.)
There are nice solutions already posted above, here's another at random.
-
Insert a space character between any two characters in a string
Hello
I'm trying to put a space between each two characters in an input string. I only got the VI to work after the first 2 characters. Can you help me get the space after both 2 characters?
Thank you
hiNi
I was thinking more like this
-
How can we remove the present space in the string in BlackBerry?
Hello
Suppose I have string like "New York". How can I remove the space between and do like "New York". As BlackBerry does not support the Java replaceAll() method, I am not able to do.
Thank you...
StringUtilities.removeChars (...)
-
I have a string where there is a particular sequence, I want to replace.
The sequence is ' / p e r.
I tried replaceAll ("-p e r," ""); Tried to replace the charsequence, but doesn't have too much work.
I am able to replace / by replaceAll("\\\","")
Somehow if I put string a = "/ p e r ' and
a.Replace ("" p e r ", pr) then came out / pr.
But I read this to a BLOB field and there spaces between the two string operations fail somehow.
Can someone help me on this please. I'm stuck for some time
Please also let me know if this isn't the right group, because I don't have an answer during my last post here
See Delete white spaces from strings in Java - Stack Overflow
-
Insert the sequence inside the string number
Hello
What is the easiest way to insert sequences of numbers within the string, exampleCan I have numbers of from 1 to 25, but I can't for the 'gaps', when this happens I filled with X01020304050607080910 = > > > 01020304050607080910XXXXXXXXXXXXXXX01030405060708091112 is > 01X03040506070809X1112XXXXXXXXXXXXXHow do I, I tried to use the TRANSLATE function, but no wayWITH the DATA (str) AS (SELECT ' 010203070911131516' FROM dual UNION ALL
SELECT "0205060809" FROM dual UNION ALL
SELECT '03050608091012' FROM dual)
, decompose AS (SELECT str, substr (str, (LEVEL - 1) * 2 + 1, 2) as ELEMENT, LENGTH (str) / 2 as items)
, MIN (substr (str, (LEVEL - 1) * 2 + 1, 2)) OVER (PARTITION BY str) AS min_element
, max (substr (str, (LEVEL - 1) * 2 + 1, 2)) OVER (PARTITION BY str) AS max_element
FROM THE DATA
CONNECT BY LEVEL<=>=>
and prior str = str
AND PRIOR sys_guid() IS NOT NULL)
COMPLETE AS (SELECT str, level elem
FROM (SELECT DISTINCT min_element, max_element, str
TO decompose) x
CONNECT BY LEVEL<= to_number(max_element)="" -="" least(to_number(min_element),1)="" +="">=>
AND str = str PRIOR
AND PRIOR sys_guid() IS NOT NULL)
SELECT c.str, listagg (NVL (d.element, 'X')) within the Group (order by c.elem)
C COMPLETE
LEFT OUTER JOIN decompose d ON (c.str = d.str
AND c.elem = to_number (d.ELEMENT))
C.str group
order of c.str;
HTH
-
Removal of invalid spaces from a string
Hi all
I have a pl/sql string that has "new line", "Form Feed", "Carriage return", "space, Horizontal / vertical Tab" and many white space characters.
For example:
Variable1 varchar2 (3000);
Variable1 = ' Hello World Hello World
Hello everybody, Hello World Hello World
Hello everyone"
I need a motion to remove all spaces (specifically, it must remove \f,\t,\n,\v,\r) and the string must sees itself as below
1 = var "" Hello World Hello World Hello World Hello World Hello World Hello everyone " "
Help, please. Thanks in advance.
\s will do the same thing as [: space:] and includes [\t\r\n\v\f]
You can add [: cntrl:] to include any other potential garbage
SELECT
REGEXP_REPLACE)
"Hello World Hello World
Hello everybody, Hello World Hello World
Hello World ",
"[[: cntrl:] [: space:]] + ',' ') r"
OF THE DOUBLE
R
' Hello World Hello World Hello World Hello World Hello World Hello world.
Maybe you are looking for
-
Download several languages in firefox and thunderbird easier
I use English and Dutch girlfriend in Thunderbird and Firefox.Alist various languages in Firefox and Thunderbird separately to be accessible easily would be much appreciated. Too much and too long at the present time research
-
Hello again I imported a playlist in itunes, but there are a lot of exclamation mark next to the name, my question is... is there a way to bulk delete these instead of to highlight each individual/group (I'm aware of the cmd shift for a group)
-
Motherboard is toast. A few questions.
Hi all First is an intro and a few features: My name is Scotty and this is my friends HP desktop that we talk... not mine. I'm an old man of mainframe that has also a dozen of Windows network, server and desktop support experience. This is the Offic
-
CCTK V2.2.1 problem with password Admin actions
Nice day. I am trying to configure a build custom offline process and I implemented a WinPE image with a few controls and remote files ini FILE to configure the BIOS settings for the technicians in offline mode. I hit a deer where CCTK put my Admin
-
I installed creative cloud and select filters and versions, does not come out earlier versions. I have to configure?