I need to declare a string like below
ext = "EXT
But I am not able to achieve it.
I tried below code and it is not worked
ext = '"EXT'
above code giving null only
Please help me
Thanks in advance
You have given extra space before and after the =
The second way which you tried and suggested in other answers will work:
ext='"EXT'
You may try using escape character "" and try something like this :
ext="\"EXT"
ext='"EXT' should work (at least in bash).
You have space between ext and equal sign. That could be a problem.
Related
I have a list in which there are more than one items. Now I want to get first element's value of tRecordCount. I am trying, but getting an error System.FormatException: Input string was not in a correct format.
Can anyone tell me what is wrong in this code?
((HiddenField)GridViewPagingControl.FindControl("TotalRows")).Value = Convert.ToString(List.First(item => item.tRecordCount == Convert.ToInt32("tRecordCount")));
I have tried FirstOrDefault and Single too, but none is working. The return type of tRecordCount is int.
Thanks in Advance
May be what you want is this.
((HiddenField)GridViewPagingControl.FindControl("TotalRows")).Value = Convert.ToString(List.First().tRecordCount);
you have problem at statement
Convert.ToInt32("tRecordCount")
correct syntax in
Convert.ToInt32("/*valid integer value*/")
if tRecordCount is variable then this statement should be
Convert.ToInt32(tRecordCount)
What's wrong is:
Convert.ToInt32("tRecordCount")
You cannot convert string to int
I am trying to use regex generators to create an expression, but I can't seem to get it right.
What I need to do is find the following type of string in a string:
community_n
For example, within the string which may be
community community_1 community_new_1 community_1_new
from that, I just want to extract community_1
I have tried /(community_\\d+)/, but that is clearly not right.
Try adding word boundries, so
/(\\bcommunity_\\d+\\b)/
Try using the regex (community_\d+).
Though I could be incorrect since I don't know which language you are using.
(For some reason I cannot add comments, I can only answer questions).
I have a string which looks like this 512.3 is there a way to add a trailing zero so it looks like this 512.30
Just to clarify (sorry I didn't know there where different ways etc.)
My string is an amount which is passed so changes all the time I only need the trailing zero on amounts like 512.3, 512.4,512.5 etc. as some of my amounts will pass values like 512.33 and 512.44 and so on
Thanks
Jamie
float.Parse("512.3").ToString("0.00");
It would give the number with two decimal digits.
You're going to want to use String.Format or some derivation thereof, and the format string will look like
myString = String.Format("{0:F2}",myObject);
Also note that format strings can be used in the .ToString("F2") method (notice I included the format string F2 inside there already.
See the MSDN links above for a more thorough and definitive explanation.
If it's VB.NET it seems like the simplest solution would be:
FormatNumber("512.3", 2)
Which would return 512.30
Format(5.12, "0.00") this will format it as two decimals.
You'll want to use String.Format
decimal your_number = 1452.66m;
string str = String.Format("{0:C}", your_number);
Single.Parse("512.3").ToString("0.00") ' VB Version
When I have an Expression declared like
someText = Regex.Replace(someText, #"/*.*?*/", "");
The Error Says
System.ArgumentException: par"/*.*?*/"
parsing - Nested quantifier *.
How to rewrite the code to avoid this error?
It doesn't like that you have this: ?*
This basically translates to "zero or one of the previous expression zero or more times" which seems a little odd. I'm pretty sure that's the same thing as saying "zero or more times". Can you explain what you are trying to do in more detail?
I suspect that if you change your regex to this it will do what you want:
(/*.*)*/
Maybe what is needed is a verbal description or sample of what you are trying to match. Here is my guess of what you want. I just added an escape for the "?" character.
string someText = Regex.Replace(someText, #"/*.*\?*/", "");
It appears you're trying to parse /* */ style comments. You may wish to try a regex like:
someText = Regex.Replace(someText, #"/\*.*\*/", "");
This ensures that your * are escaped as actual characters.
Here is a good site to test your regular expressions without much trouble:
http://www.regular-expressions.info/javascriptexample.html
I hope this will help a bit.
This seems like it should be a simple thing to do, but I can't figure it out.
I have a localized resource that I'm using in two places - one as a col. header in a datagrid, and then as a descriptor beside a field when the user edits a row.
The text of the label looks like:
Text="<%$Resources:Global,keyName%>"
However, I'd like to add a trailing : to the label - except if I change the above to
Text="<%$Resources:Global,keyName%>:"
then the : is the only thing that shows up! I've tried it with simple strings, so there's nothing special about the colon char that causes this.
Surely I don't have to have 2 different resources?
Have you tried Text="<%$Resources:Global,keyName%>" + ":" ?
You'd basically be concatenating two strings. Or treat them as two strings
StringBuilder t;
t.append(<%$Resources:Global,keyName%>)
t.append(":")
Text = t;
Assuming you need to keep the : together for styling reasons, replace the label with a span:
<%=Resources.Global.keyName %>:
Well, sometimes the obvious isn't so obvious until someone else looks at it:
Text="<%$Resources:Global,keyName%>" /> :
Just move the : outside the label tag, and all is well.