What's the best regular expression for integer separated by comma? It can also contain space between comma, and the field is not required which means it could be blank.
123,98549
43446
etc..
One-Liner to list TXT-files.
import java.io.File;
import java.io.FilenameFilter;
...
files = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".txt");
}
}
);
Source.
Is there an one-liner to list dirs in a dir?
I am trying to sort the following table:
hYear hSale
------------------------------------
[year] =Count(Fields!sale.Value)
The table only has one row group (year) and no column group.
I'd like to:
-initially sort the table based on the calculated value; is it possible?
-add interactive sort to calculated column based on the value. I assume I should sort 'Detail rows', but what will be the sort expression?
I have 300 boolean fields in one table, and im trying to do somithing like that:
One string field:
10000010000100100100100100010001
Ha a simple way to do a simple search os this field like:
select * from table where field xor "10000010000100100100000000010001"
Im tring this but is to long:
select * from teste where mid(info,2,1) and mid(info,3,1)
:) Help!!
I need an expression to capture a string like this
"A"[A string that is NOT atleast 5 and atmost 6 digits]"B", In other words capture anything that is NOT the following
A[0-9][0-9][0-9][0-9][0-9]B
A[0-9][0-9][0-9][0-9][0-9][0-9]B
I have tried the negative look ahead
regex = "a((?![0-9]{5,6}).)*d" ;
But it fails to capture all scenarios.
Please help
venu
I'd like to create a list of method-object pairs. Each method is a function returning a boolean. Then:
foreach(pair) {
if method evaluates to true {
do something with the object
}
}
One way of modelling this that I can think of is to have a class Constraint with a method isValid() and for each constraint produce an anonymous class (overriding the isValid() method). I feel like there could be a nicer way. Can you think of any?
//
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()) {
case EXIT:
try {
this.finish();
} catch(Exception e) {
}
break;
}
return false;
}
When I exit my android application it resumes the previous screen. How can I exit the Android application properly?
I am wondering what this technique is called and what it does. It seems to be validating some regular expression on the variable url. I am customizing another persons code:
var url = document.getElementById("editorURL").value;
if(/(file|http).*/.test(url)) {
}
Maybe someone has a link to an article that explains this a bit more in-depth?
As its a pain to handle structural changes of the class in two places I often do:
class A {
private B bChild;
private C cChild;
private Object[] structure() {
return new Object[]{bChild, cChild};
}
int hashCode() {
Arrays.hashCode(structure);
}
boolean equals(Object that) {
return Arrays.equals(this.structure(), ((A)that).structure());
}
}
What's bad about this approach besides boxing of primitives?
Can it be improved?
Class<? extends Algorithm> alg = AlgorithmAllFrom9AndLastFrom10Impl.class
Constructor<Algorithm> c = alg.getConstructors()[0];
For "alg.getConstructors()[0];" I am getting a warning in eclipse
Type safety: The expression of type
Constructor needs unchecked conversion
to conform to Constructor
How do I fix this?
I'm trying to create a WCHAR:
LONG bufferSize = foo.bar() + 1;
WCHAR wszBaz[bufferSize];
The compiler issues an error:
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'wszBaz' unknown size
What am I doing wrong?
UPDATE: I added const but it still gives the same error:
const LONG bufferSize = foo.bar() + 1;
WCHAR wszBaz[bufferSize];
Sorry for this english related question but I only came across that expression in the context of IT. What does abstracting over something mean ? For example abstracting over objects or abstracting over classes.
Thanks
I have a screen with three listviews, each having three different cursors, but all have the same ContextMenu show/resolve code and when the selection event fires, I want to get the ListView to refresh it.
I can't use menuInfo.targetView, as that holds the LinearLayout for the ListView row, and not the ListView.
in this method
public boolean onContextItemSelected(MenuItem item)
How is possible?
How do I restrict a string to whitelisted characters?
// "HOW am I to understand; this is, BAD"
$str = restrictTo($str,"0-9a-z,. ");
// " am I to understand this is, "
Is there an inbuilt function in PHP that does something close? I can't formulate a regular expression for this though :(
static void Main()
{
string[] a = { "a", "asd", "bdfsd", "we" };
a = a.OrderBy(fun).ToArray();
}
private static int fun(string s)
{
return s.Length;
}
its is giving compile time error . I know that we can do this with Lambda expression like this. a.OrderBy(s=>s.Length).ToArray(); but i want to this do by defining different function . What mistake i have done?
hey,
I have two-dimension array
List<List<int>> boardArray
How can I enumerate throw this array to check that it contains other value than 0 ?
I think about boardArray.Contains and ForEach ,cause it return bool value but I don't have too much experience with lambda expression :/
Please help :)
Hi everyone.
I want to search my link on other pages by passing url address.
After passing the url it should return some boolean value which will define the existence of my link.
Preferred language ASP.net/C#
If it is possible, Please help me.
Why I can't construct large tuples in Haskell? Why there's a tuple size limit?
Prelude> (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
<interactive>:1:0:
No instance for (Show
(t,
t1,
t2,
...
t23))
arising from a use of `print' at <interactive>:1:0-48
Possible fix:
add an instance declaration for
(Show
(t,
t1,
t2,
...
t23))
In a stmt of a 'do' expression: print it
I have a custom control I created from a expression design I created and exported to xaml. I have put in it a bound itemtemplate/datatemplate of a ListBox contorl. It doesn't seem to be rendering more than once and/or it is rendering each item in the same place(kind of like the same x,y coordinates.
I'm using the following code to check the access on selected folder. but it's not working.
private boolean writeAccess(String path){
try {
AccessController.checkPermission(new FilePermission(path, "read,write"));/*,*/
// Has permission
return true;
}
catch (SecurityException e) {
// Does not have permission
return false;
}
}
wt is prblm in it. and is there any other options to check the existance and access on the folders/directories?
Hi, all.
I'm trying to convert an all-uppercase string in Ruby into a lower case one, but with each word's first character being upper case. Example:
convert "MY STRING HERE" to "My String Here".
I know I can use the .downcase method, but that would make everything lower case ("my string here"). I'm scanning all lines in a file and doing this change, so is there a regular expression I can use through ruby to achieve this?
Thanks!
I just had to write the most redonkulous expression in an SSIS Derived Column to get dates formatted like "01-JAN-2010". It lookes like this:
There's got to be a better way... isn't there?
I am running
ruby script/generate scaffold
or
ruby script/generate model
and I know the basic syntax, like
ruby script/generate scaffold Dude name:string face:boolean
but I do not know things like:
should names of variables have
underscores or be camelCased?
what
kind of variable types are
acceptable?
Where can I find such information?
THANKS!
P.S. The answers to my two questions would help for now, too :)
I'm wondering specifically what experienced programmers thought when they started developing in Python. I'm sure the answer depends on your background, but my own personal answer is the conversion of basically anything in the language to a True/False value in boolean contexts.
Resulting in "oddities" like:
if x:
not meaning the same thing as:
if x == True:
I understand why, but it bugs me, and I certainly had to think about it a bit when I first ran into it.