Hi,
Lets say I have a string " Hello World"
How can I use a regular expression to return the number of spaces I have in the string. In this case it would be '2'.
Thanks
I've always been one to simply use List<String> names = new ArrayList<String>();
I use the interface as the type name for portability, so that when I ask questions such as these I can rework my code.
When should LinkedList should be used over ArrayList and vice-versa?
How do I create an array in smarty from a given string like 22||33||50 and look if the given number is like the numbers above in smarty ?
I have a string say
{$test->strings} // contains 33||12||80
I want to look if one of the numbers in {$test->strings} is equal to {$test->myday}
how can I do that?
Currently i have sql-server nvarchar(max) column which has text that starts with
"""
The only thing that varies in the pattern is the < in the class name.
The common part is
""
Some sample values are
""
""
""
All the
These span text are present only at the beginning of the column. Any such matching span in the middle should not be removed or matched.
Whats the sql server query with regex to remove all these occurance of span?
For example, I make a fullName property and set it to transient. Does it matter what data type that property is, in this case? For example, does it matter if it's set to int or string?
As far as I get it, a transient property is almost "ignored" by Core Data. I make my accessors for that and when someone accesses fullName, I simply construct a string and return that.
Did I miss something?
What's the simplest way of printing an array of primitives or of objects in Java? Here are some example inputs and outputs:
int[] intArray = new int[] {1, 2, 3, 4, 5};
//output: [1, 2, 3, 4, 5]
String[] strArray = new String[] {"John", "Mary", "Bob"};
//output: [John, Mary, Bob]
I am trying to use HG (Mercurial) with the Vim VCScommand plugin, but am running into a problem "Too many matching VCS: git HG". I removed the vcsgit.vim and the HG binding seemed to work. I thought VCScommand used the folder to determine, which VCS one was using. I guess this is a flawed assumption.
HTML has an input button type to reset all fields in a form to their initial state in one step: <input type="reset" ... />.
Is there a similar simple way to reset all form fields of an aspx page from code-behind? Or is it necessary to reset all controls one by one with TextBox1.Text=string.Empty, TextBox2.Text=string.Empty, etc. ?
Thanks in advance!
I am new to c# and need help understanding what going on in the following function
public bool parse(String s)
{
table.Clear();
return parse(s, table, null);
}
where table is a Dictionary. I can see that is is recursive but how is parse being passed three params when it is defined to take just a string?
I have array of colors:
String s[]=new String[]{"red","black..............};
The only possible colors are red and black. I need an algorithm which partitions the array such that all red come before all black. How can I compare/exchange them to accomplish that?
I'm having trouble figuring out the syntax for a JScript .NET dictionary object. I have tried
private var myDictionary: Dictionary<string><string>;
but the compiler complains that it's missing a semicolon and that the Dictionary object is not declared.
I know JScript does have a native dictionary-like object format, but I'm not sure if there are disadvantages to using it instead of the .NET-specific construct. I.e., what if someone wants to extend my script using another .NET language?
I'm trying to filter webserver log files using grep. I need to output all lines containing 65.55. but exclude those matching lines which contain msnbot.
My starting point is this - but it doesn't work:
grep "^.*65\.55\..*(!msnbot).*$" ex100101.log > results.txt
I'm using grep for Windows (hence double quotes) but I doubt this matters.
This is not working for me:
public bool createRegistry()
{
if (!registryExists())
{
Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\xelo\\");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\xelo").SetValue("hostname", (string)hostname, Microsoft.Win32.RegistryValueKind.String);
return true;
}
else
{
return updateRegistry();
}
}
The exception error is to do with Not Authorized to do this. Any Help would be apreaciated
Exeption: System.UnauthorizedAccessException | "Cannot write to the registry key"
What i want to do is:
I have css file read from a file into a String. I would like to build some kind of css resource (CssResource ?) out of that string or file, and I'd like to be able to extract from it all classes and id selectors in some kind of collection which i could search.
Does anybody know how to do that ?
Hi All,
I am using Apache POI to store data in excel sheet. I can store data like "50%" in the cell. Excel also shows up, but it show error like "Number stored as String".
If i click that message and click "convert number to String". It shows perfectly.
How to store it without errror using POI
I have an entity with Integer attributes that looks like this in proto code:
class MyEntity:
String name
Integer frequency
Integer type
def getFrequency()
def getType()
get* accessors return strings according to this table.
value(type) HumanReadableString(type)
1 BSD
2 Apache
3 GPL
min frequency max frequency HumanReadableString(frequency)
0 1000 rare
1000 2000 frequent
2001 3000 sexy
It should be possible to get all possible values that an attribute can take, example:
getChoices(MyEntity, "type") returns ("rare", "frequent", "sexy")
It should be possible to get the bound value from the string:
getValue(MyEntity, "frequency", "sexy") returns (2000,3000)
Hi.
I need to customize the listview,I am placing an icon and a text at the center of the listview.
If the text length is bigger then the list rectangle length.. the text is coming over the icon first letter of the string is not visible..
How to avoid this situation? Is it possible to give marique effect for the string?
Thanks in advance.
I have a batch file that I want to improve. Instead of requiring a user to provide a folder path without a trailing slash, is there an easy way for me to just remove the last character from the path if there is a slash on the end?
:START
@echo What folder do you want to process? (Provide a path without a closing backslash)
set /p datapath=
::Is string empty?
IF X%datapath% == X GOTO:START
::Does string have a trailing slash?
IF %datapath:~-1%==\ GOTO:START
If I make an empty test class:
public class Foo
{
}
And I try to compile code with this statement:
Foo foo = "test";
Then I get this error as expected:
Cannot implicitly convert type 'string' to 'ConsoleApplication1.Foo'
However, if I change the declaration of Foo from class to interface, the error changes to this (emphasis mine):
Cannot implicitly convert type
'string' to 'ConsoleApplication1.Foo'.
An explicit conversion exists (are you
missing a cast?)
What is this "explicit conversion" which is supposed to exist?
I currently have a PHP form that uses AJAX to connect to MySQL and display records matching a user's selection (http://stackoverflow.com/questions/2593317/ajax-display-mysql-data-with-value-from-multiple-select-boxes)
As well as displaying the data, I also place an 'Edit' button next to each result which displays a form where the data can be edited. My problem is editing unique records since currently I only use the selected values for 'name' and 'age' to find the record. If two (or more) records share the same name and age, I am only able to edit the first result.
This is my test-string:
<img rel="{objectid:498,newobject:1,fileid:338}" width="80" height="60" align="left" src="../../../../files/jpg1/Desert1.jpg" alt="" />
I want to get each of the JSON formed Elements inbetween the rel attribute.
It's working for the first element (objectid).
Here is my ReqEx, which works fine:
(?<=(rel="\{objectid:))\d+(?=[,|\}])
But i want to do somthing like this, which doesn't work:
(?<=(rel="\{.*objectid:))\d+(?=[,|\}])
So i can parse every element of the search string.
I'm using Java-ReqEx
Hello,
I get input (x) from user, convert it to Int by let y = (read x)::Int and then I would like the function to behave in a special way if user gave nothing (empty string).
-- In this place I would like to handle situation in which user
-- gave empty string as argument
-- this doesnt work :/
yearFilter [] y = True
--This works fine as far as y is integer
yearFilter x y | x == (objectYear y) = True
| otherwise = False
Thanks for help,
Bye
I am getting a "DOS" instead of the html string ....
let getHtmlBasic (uri :System.Uri ) =
use client = new WebClient()
client.DownloadString( uri)
let uri = System.Uri( "http://www.b-a-r-f.com/" )
getHtmlBasic uri
This gives a string, "DOS"
Lol what the ?
All other websites seems to work ...
Is there a better way to track the selected item than how I do it in the code below which implements a row of navigation links.
@Html.ActionLink(
"PreApproval",
"Summary",
new { mode = "preapproval" },
new { @class = Model.Mode == "preapproval" ? "selected" : "notselected" }) |
@Html.ActionLink(
"ActionNeeded",
"Summary",
new { mode = (string)null },
new { @class = string.IsNullOrWhiteSpace(Model.Mode) ? "selected" : "notselected" }) |
...
Should I try to encasulate the functionality of menu navigation or is this a standard approach?
I want to use linq to get datarow array from a datatable which its string type ColumnA is not null or depending on its length 0 , so I can get the row index with Indexof() method to deal with something else.
ColumnA ColumnB ColumnC
A0 B0 C0
Null B1 C1
A2 B2 C2
Null B3 C3
My Linq Statment:
DataRow[] rows = myDataTable.Select("ColumnA is not null").Where(row=>row.Field<string>("ColumnA").Length>0);
somebody who can help?