As3 Split on a Carriage Return - string

Can anyone tell me how to use the split() function in as3 to split Strings with Carriage Returns?
This is usually done with " \n ", but it doesent seem to work in this case, with or without de quotes.

Try spliting like this
var yourArray:Array = YourString.split(String.fromCharCode(13));

Related

How can I do line breaks in a formatted string string python3

simple question that I hope has a simple answer
I want to store a formatted string to pass later to function call. I would like to have line breaks baked into one long string rather than send a string for each line. So for example
b = f'hello \n world'
b
this gives me 'hello \n world' which is not what I want.
How can I do this in a compact manner. I would prefer to avoid joins or something like that with a newline separator.
Thanks in advance.

How to get a substring of this string Python3

string:
ecsdcsdcsdfvdfv":"https://scdsscdcsdent-mxp1-1.cdninstdscsdcagdssdcsdam.com/v/t51.283485-19/s320x320/79000872_1455436197941341_7513464347075543040_n.pnk?_nc_ht=scontent-mxp1-1.cdninadcdcdm.codcsdcm&_nc_ohc=0fehqjedb48AX8r72Hi&oh=eb1f6a78a2dcd67e443aa7f74eee91b4&oe=5E7F0A0C","vsvdfvsfvcfvfdcvfd
substring that i want to get:
https://scdsscdcsdent-mxp1-1.cdninstdscsdcagdssdcsdam.com/v/t51.283485-19/s320x320/79000872_1455436197941341_7513464347075543040_n.pnk?_nc_ht=scontent-mxp1-1.cdninadcdcdm.codcsdcm&_nc_ohc=0fehqjedb48AX8r72Hi&oh=eb1f6a78a2dcd67e443aa7f74eee91b4&oe=5E7F0A0C
i tried this but doesn't work
print (log.split("ecsdcsdcsdfvdfv",1)[1])
You can try this
log.split('":"')[1].split('","')[0]
But this is not the best way to do what you are trying to achieve. Better parse it and get what you want.
This yield the expected result.
The way you used .split() was wrong, you did not include the " character.
string = 'ecsdcsdcsdfvdfv":"https://scdsscdcsdent-mxp1-1.cdninstdscsdcagdssdcsdam.com/v/t51.283485-19/s320x320/79000872_1455436197941341_7513464347075543040_n.pnk?_nc_ht=scontent-mxp1-1.cdninadcdcdm.codcsdcm&_nc_ohc=0fehqjedb48AX8r72Hi&oh=eb1f6a78a2dcd67e443aa7f74eee91b4&oe=5E7F0A0C","vsvdfvsfvcfvfdcvfd'
substring = string.split('ecsdcsdcsdfvdfv":"')[1].split('","vsvdfvsfvcfvfdcvfd')[0]
If you want to get the string between the ":" and ",", then you can use regular expression to do it.
re.match('(.*\":\")([^\",\"]*)(\",\".*)', log).group(2)
Given your input
'ecsdcsdcsdfvdfv":"https://scdsscdcsdent-mxp1-1.cdninstdscsdcagdssdcsdam.com/v/t51.283485-19/s320x320/79000872_1455436197941341_7513464347075543040_n.pnk?_nc_ht=scontent-mxp1-1.cdninadcdcdm.codcsdcm&_nc_ohc=0fehqjedb48AX8r72Hi&oh=eb1f6a78a2dcd67e443aa7f74eee91b4&oe=5E7F0A0C","vsvdfvsfvcfvfdcvfd'
you will get
'https://scdsscdcsdent-mxp1-1.cdninstdscsdcagdssdcsdam.com/v/t51.283485-19/s320x320/79000872_1455436197941341_7513464347075543040_n.pnk?_nc_ht=scontent-mxp1-1.cdninadcdcdm.codcsdcm&_nc_ohc=0fehqjedb48AX8r72Hi&oh=eb1f6a78a2dcd67e443aa7f74eee91b4&oe=5E7F0A0C'
And if you input something like
'ecsdcsdcs":"dfvdfv":"https://s...F0A0C","vsvdfvsfvcfvfdc","vfd'
you will get
'https://s...F0A0C'
Dont forget to import re.

string parts seperated by ; to ASCII written in a new string

Something like that is coming in:
str="Hello;this;is;a;text"
What I do want as result is this:
result="72:101:108:108:111;116:104:105:115;..."
which should be the Text in ASCII.
You could use string matching to get each word separated by ; and then convert, concat:
local str = "Hello;this;is;a;text"
for word in str:gmatch("[^;]+") do
ascii = table.pack(word:byte(1, -1))
local converted = table.concat(ascii, ":")
print(converted)
end
The output of the above code is:
72:101:108:108:111
116:104:105:115
105:115
97
116:101:120:116
I'll leave the rest of work to you. Hint: use table.concat.
Here is another approach, which exploits that fact that gsub accepts a table where it reads replacements:
T={}
for c=0,255 do
T[string.char(c)]=c..":"
end
T[";"]=";"
str="Hello;this;is;a;text"
result=str:gsub(".",T):gsub(":;",";")
print(result)
Another possibility:
function convert(s)
return (s:gsub('.',function (s)
if s == ';' then return s end
return s:byte()..':'
end)
:gsub(':;',';')
:gsub(':$',''))
end
print(convert 'Hello;this;is;a;text')
Finding certain character or string (such as ";") can be done by using string.find - https://www.lua.org/pil/20.1.html
Converting character to its ASCII code can be done by string.byte - https://www.lua.org/pil/20.html
What you need to do is build a new string using two functions mentioned above. If you need more string-based functions please visit official Lua site: https://www.lua.org/pil/contents.html
Okay...I got way further, but I can't find how to return a string made up of two seperate strings like
str=str1&" "&str2

remove backslash from string lua

I working with some url string and i tried to remove "\" from the string to use url for my further use.
But when i tried using strin.gsub its not working as it should. rather then its giving me wrong output.
the String is
nas="\\192.168.1.220\STORAGE_1d1b7\a\b\c"
Code I have tried:
nas=string.gsub(nas,'\\',"")
print(nas)
Output:
192.168.1.220STORAGE_1d1b7??c
Output i need:
192.168.1.220STORAGE_1d1b7_a_b_c
its removing the "\" but it also affecting the "\" with "?"
i don't know where the "?" comes from?
The character \ is used to escape some special characters in a string, for eg.: \n represents a newline character (ASCII code 10) etc. (\a is ASCII code 7 in C/C++)
So, you'd need to define your string as:
nas = "\\\\192.168.1.220\\STORAGE_1d1b7\\a\\b\\c"
Alternatively, lua provides another way to define raw strings:
nas = [[\\192.168.1.220\STORAGE_1d1b7\a\b\c]]
Any ways Figured it out....
NASLocation = NASLocation:gsub('\\\\', ''):gsub('\\', '_',1):gsub('\\','/')

VB6 Split String with < > Characters

I am trying to split something like this
When the Source is from a webpage and contains this value multiple times, but I don't think will split it because of the "<" character, any way around this?
SourceSplit = Split(Source, "<span class='BText' id='BText'>")
I tried using Chr(60) instead, didn't like that either, any ideas?
Thanks for any help
I would guess that the HTML uses double quotes for attribute values, not single. You need to escape the double quotes:
SourceSplit = Split(Source, "<span class=""BText"" id=""BText"">")

Resources