My app receives numerous text strings which may or may not contain a URL anywhere within the string. What would be the best method to extract a URL from within a string? Thank you.
I'm trying to print strings in one line.
I've found solutions but they don't works with windows correctly.
I have text file contains names and I want to print them like this
name=john then change john to next name and keep name=, I've made this code but didn't work correctly with windows:
op = open('names.txt','r')
print 'name=',
for i in op.readlines():
print '\r'+i.strip('\n')
thank you for your time
I'm in need for a data structure that can handle small sets (10-20 strings, at most 50, of varying length) very fast. False positives is ok, but false negatives are not.
The last requirement makes bloom filters seem like a good fit, but I'm not sure about their speed, any other recommendations?
I have to create a C# application which displays unicode data in a textbox.
But the SQL server column storage has varchar data which contains unicode data. But since varchar is non-unicode based it displays character strings like "????????".
Well the problem i am facing is i cant change the column type as there are other dependent application running on it.
Sample Data :
input : "abcdacdc"
Output : "cadb"
here we have to sort strings in order of count of characters.
If the count is same for characters. maintain the original order of
the characters from input string.
my approach: i have used array of 26 for maintaining occurrence of all characters and sort it then print it.But while doing so i am not able to maintain order in case if two characters have same count.
please suggest any improvement or any other algo.
I'm using this code:
s = line.match( /ABCD(\d{4})/ ).values_at( 1 )[0]
To extract numbers from strings like:
ABCD1234
ABCD1235
ABCD1236
etc.
It works, but I wonder what other alternative I have to to this in Ruby?
Hello world!
Using the following code:
Function GetSetting(Of T)(ByVal SettingName As String, ByRef DefaultVal As T) As T
Return If(Configuration.ContainsKey(SettingName), CType(Configuration(SettingName), T), DefaultVal)
End Function
Yields the following error:
Value of type 'String' cannot be converted to 'T'.
Any way I could specify that in all cases, the conversion will indeed be possible (I'm basically getting integers, booleans, doubles and strings).
Thanks!
Are they same ?
Came across this line when reading about Java's main method's signature
"String args[ ] declares a parameter named args, which is an array of instances of the class String. Objects of type String store character strings."
Whats the easiest way in javascript to replace ABC, DEF, GHI with XYZ in the following strings
http://z.site.com/z/ABC/z/z.html
http://z.site.com/z/DEF/z/z.html
http://z.site.com/z/GHI/z/z.html
I have two Ruby arrays, and I need to see if they have any values in common. I could just loop through each of the values in one array and do include?() on the other, but I'm sure there's a better way. What is it? (The arrays both hold strings.)
Thanks.
Hello,
Is there a way to declare a string variable in python such that everything inside of it is automatically escaped, or has its literal character value? I'm NOT asking how to escape the quotes with slashes, that's obvious. What I'm asking for is a general purpose way for making EVERYTHING in a string literal so that I don't have to manually go through and escape everything for very large strings. Anyone know of a solution? Thanks!
Sorry if this has been asked before but I can't find it. I am looking for an authoritative description of all valid strings that can be used as a reference, e.g., "A1:C5", "$A:$A", $A2" etc etc. That seems a pretty basic thing yet I've wasted hours trying to locate it. All I can find is a swamp of "helpful" examples but no reference.
So I have this existing command that accepts a single argument, but I need something that accepts the argument over stdin instead.
A shell script wrapper like the following works, but as I will be allowing untrusted users to pass arbitrary strings on stdin, I'm wondering if there's potential for someone to execute arbitary commands on the shell.
#!/bin/sh
$CMD "`cat`"
Obviously if $CMD has a vulnerability in the way it processes the argument there's nothing I can do, so I'm concerned stuff like this:
Somehow allow the user to escape the double quotes and pass input into argument #2 of $CMD
Somehow cause another arbitary command to run
I'm reading a comma-delimited list of strings from a config file. I need to check whether another string is in that list. For example:
"apple,banana,cheese"
If I check for "apple" I should find it, but if I check for "app" I should not.
What's the most straight-forward and concise way to do this? It doesn't have to be fast.
(I'll add my solution as an answer, but I'm hoping someone has something better.)
I've got a utility that outputs a list of files required by a game. How can I run that utility within a C program and grab its output so I can act on it within the same program?
UPDATE: Good call on the lack of information. The utility spits out a series of strings, and this is supposed to be complete portable across Mac/Windows/Linux. Please note, I'm looking for a programmatic way to execute the utility and retain its output (which goes to stdout).
is there a built in function in php that would combine 2 strings into 1?
example: $string1 = abcde, $tring2 = cdefg
combine to get: abcdefg
if the exact overlapping sequence and the position are known, then it is possible to write a code to merge them.
TIA
I'm developing an interpreter and I have some questions to it.
I recently saw a small C interpreter that used a very simple struct like the below for all its objects/values in the language:
struct Object
{
ubyte type;
ubyte value;
};
This struct can hold strings, integers, bools and lists (I think) used in the language the interpreter is working with.
How can you get this Object struct to hold all these types?
I have a string which is fed into the query as IN clause,which looks like this ('ACT','INACT') which is one of the parameters to a function inside a package.when a call is made to the function from java,
it looks like this
call package.function(1,2,3,('ACT','INACT'),4,5).
When the package is called,i get error as wrong type of arguments.
It is taking the values inside brackets as different values delimited by strings
Format is like:
CHINA;2002-06-25 00:00:00.000;5,60
CHINA;2002-06-26 00:00:00.000;5,32
CHINA;2002-06-27 00:00:00.000;5,31
and I try to use Python's CSV tools to parse it but cannot understand the paragraph, source:
And while the module doesn’t directly support parsing strings, it can easily be done:
import csv
for row in csv.reader(['one,two,three']):
print row
Could someone clarify the line ['one,two,three']? How would you use it with format A;B;C?
Hello Guys,
I am new to TCL and seeking a help to deal with the following expression.
I am getting the i/p string from the user to validate any of these strings below & no others in a line in CLI
{ GHI GII GJI GKI}
and another tricky one is to write regexp to match only the characters which begin with alphabet A & end with B, It also have 1 or more of either YO or OY in between using procedure.
Thank you
Some time ago I had a look into Ruby and one of the things which stood out most for me was the way of using symbols.
While you to use defines or strings like in C++ or Python as an alternative, in Ruby you just write :mySymbol and the interpreter takes over the enumeration for you.
I can't see any disadvantage this feature has, so why is it missing in say, PHP and Python?
When we write a program which supports both unicode and multibytes,
we often use _T("some string") macro for strings.
But, does a character also need to wrap this macro?
Are L'A' and 'A' totally same?
Don't we need to use _T('A') for a character?
Why would someone use WHERE 1=1 AND <conditions> in a SQL clause (Either SQL obtained through concatenated strings, either view definition)
I've seen somewhere that this would be used to protect against SQL Injection, but it seems very weird.
If there is injection WHERE 1 = 1 AND injected OR 1=1 would have the same result as injected OR 1=1.
Later edit: What about the usage in a view definition?
I have a bunch of strings which may of may not have random symbols and numbers in them. Some examples are:
contains(reserved[j])){
close();
i++){
letters[20]=word
I want to find any character that is NOT a letter, and replace it with a white space, so the above examples look like:
contains reserved j
close
i
letters word
What is the best way to do this?
I am trying to create a multi line string in Groovy. I have a list of strings that I'd like to loop through within the multi line string. I am not sure what the syntax is for this. Something like below...
def html = """\
<ul>
<li>$awaiting.each { it.toPermalink()}</li>
</ul>
"""