Hey, i try to trim each string item of an list in groovy
list.each() { it = it.trim(); }
But this only works within the closure, in the list the strings are still " foo", "bar " and " groovy ".
How can i achieve that?
...
$s = '1000';
after process,should be '0001'
...
Hi,
I'm using the FINDSTR function to filter text files, but it's failling on extended ASCII characters.
I tried using the CharToOEM function, but I still have characters such as 'à', which FINDSTR doesn't seems to recognize.
I want to use FINDSTR because the text files I work with are 100MB big, so I need something fast.
Does a functi...
I have a string which I read in from :
TextReader tr = new StreamReader(this.dataPath );
string contents = tr.ReadToEnd();
The value of contents begins with:
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n....."
When I try execute
string styleSheet = "<?xml-stylesheet type=\"text/xsl\" href=\"message.xsl\"?>";
str...
Background: Here the goal is to do some basic commands in powershell using select-string. For some reason, there are certain things that are not working as expected.
Assume the following:
$vfilter = 'c:/foo/bar/files/*.htm';
Select-String -path $vfilter -pattern ".*DOCTY.*" |
sort LineNumber |
where-object { $_...
I'm looking for a way to have an external file (resources, resx, assembly, config, xml, etc) editable by a user of my application.
These would mostly contains strings of text related to database field names and the like.
Preferably, something with an already existing free editor. I wouldn't mind doing an app for this if needed though.
...
In XSLT 2.0, is there an easy way to replace named placeholders in a string?
I'm thinking of something like Python's string.Template, where you can do this:
d = dict(name='Joe', age='50')
print Template("My name is $name and my age is $age").substitute(d)
The point is to externalize the string, so it can be easily changed. The only w...
Hi,
I wanted to know if there is any (easy) method to find the order of a given array of substrings in an NSString?
I have a large block of text and a few substrings. I'm only interested in the order that the substrings first appear in the text.
So if the text was "can you tell me you are working late if you can" and the substrings w...
Hi
In the following code, I copy a string in to a char* str, which is 10 characters long, using strncpy().
Now according to strncpy() manual, "Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not be null terminated. " which is exactly what happens here.
The source string is 26 charcter...
Is there any reason why a Java string cannot be tested for equality using it's hashCode method? So basically, instead of....
"hello".equals("hello")
You could use...
"hello".hashCode() == "hello".hashCode()
This would be useful because once a string has calculated it's hashcode then comparing a string would be as efficient as comp...
I got the following code:
int nnames;
String names[];
System.out.print("How many names are you going to save: ");
Scanner in = new Scanner(System.in);
nnames = in.nextInt();
names = new String[nnames];
for (int i = 0; i < names.length; i++){
System.out.print("Type a name: ");
names[i] = in.next();
}
System.out.printl...
I am curious to know how std::string is implemented and how does it differ from c string?If the standard does not specify any implementation then any implementation with explanation would be great with how it satisfies the string requirement given by standard?
...
I got the following code:
int nnames;
String names[];
System.out.print("How many names are you going to save: ");
Scanner in = new Scanner(System.in);
nnames = in.nextInt();
names = new String[nnames];
for (int i = 0; i < names.length; i++){
System.out.print("Type a name: ");
names[i] = ...
What would an implementation of 'MagicFunction' look like to make the following (nunit) test pass?
public MagicFunction_Should_Prepend_Given_String_To_Each_Line()
{
var str = @"line1
line2
line3";
var result = MagicFunction(str, "-- ");
var expected = @"-- line1
-- line2
-- line3";
Assert.AreEqual(expected, result);
}...
Pretty simple question, but this is coming from a C/C++ person getting into the intricacies of Java.
I understand I can fire up jUnit and a few performance tests of my own to get an answer; but I'm just wondering if this is out there.
Are there known difference(s) between String.replaceAll() and Matcher.replaceAll() (On a Matcher Objec...
Let's say I have the string "1e". In Java, how can I convert it to the byte 0x1e?
...
I have some static const strings as private members of my C++ class. I am aware of the declaration in .h and definition (and initialization) in .cpp practice. In the class constructor I invoke a function that uses these static strings. Surprisingly when in constructor, the strings remain uninitialized (empty strings) which is creating a ...
Is this the correct way to access a MS Office Excel 2007 file?
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + file_path + ";Extended Properties=Excel 8.0;";
If so, how do I access a certain worksheet and insert rows? Links are also welcomed.
...
how do you implement substring in C++ that returns pointer to char? (takes pointer to the first letter)
say something like char* substr(char* c, int pos, int lenght)
...
I have a string, like a sentence, and I know for sure that there are many words with at least one space separate every adjacent two. How can I split the words into individual strings so I can loop through them?
EDIT:
Bash
The string is passed in as an argument. e.g. ${2} might be "cat '' cat '' file". so how can I loop through this ar...