Regexp - Converting From JS Match To C#
Feb 4, 2010
This is probably a simple one for C# people :-) I have this regular expression in javascript:
strVar = strVar.replace(/(specificattribute=)"s*([^"]+?)s*"/g, '$1"$2"');
It replaces leading and trailing spaces inside a specific attribute's value, globally (as per this example page: [URL]). I need to do the same on a string in C#, but when trying the above, the syntax checker chokes at the regExp. So I need the equivalent line of the above in C#.
View 8 Replies
Similar Messages:
Oct 12, 2010
I am trying to match a username to a userid which are in 2 different sql tables. Here is my select statement:
SELECT aspnet_Users.UserName
FROM aspnet_Users INNER JOIN
aspnet_starterkits_Projects ON aspnet_Users.UserName = aspnet_starterkits_Projects.ProjectManagerId
When I run this i get an error message: "Conversion failed when converting from a character string to uniqueidentifier" Is there anyway around this? Or a different select statement etc?
View 8 Replies
May 1, 2010
When validating an email address with the regex validation component, an additional RequiredFieldValidator must be added to ensure there is a value present.
I've mostly taken care of this with a CustomFieldValidator, and taking care of this with Javascript.
View 1 Replies
Feb 26, 2010
I have a longer text and some keywords. I want to highlight these keywords in my text. That is no problem with this code:
private static string HighlightKeywords2(string keywords, string text)
{
// Swap out the ,<space> for pipes and add the braces
Regex r = new Regex(@", ?");
keywords = "(" + r.Replace(keywords, @"|") + ")";
// Get ready to replace the keywords
r = new Regex(keywords, RegexOptions.Singleline | RegexOptions.IgnoreCase);
// Do the replace
return r.Replace(text, new MatchEvaluator(MatchEval2));
}
private static string MatchEval2(Match match)
{
if (match.Groups[1].Success)
{
return "<b>" + match.ToString() + "</b>";
}
return ""; //no match
}
But when the word"tournament" is in the text and the keyword "tour" it becomes <b>tour</b>nament. I want to it to highlight the complete word: <b>tournament</b>.
View 1 Replies
Mar 25, 2010
I want a regex expression which only match extensionless url. In otherwords if an extension is present in url then completely ignore it.
/(.+)/(.+) this will match an URL both with and without extension.
www.site.com/sports/cricket should match
www.site.com/sports/cricket.aspx shouldn't match
View 3 Replies
Jan 5, 2011
So the case is this:
The user can provide a group of strings for a propert. ex:
DaysNeeded ="Sunday,Tuesday,Friday,Saturday";
In the actual UI, the days of the week are available as check boxes. I'm trying to provide a way so that the user can also set the days needed in the code behind through a property.
Now my query is, which strategy is the best way to execute certain pieces of code that are respective to the days that the user have provided. Meaning, the DaysNeeded property has sunday,Tuesday, Friday and Saturday. Each day has certain piece of code to be executed. If i have to have a forloop with a switch case for each day of the week, i feel it would cost more as i have to run the for loop, the number of days the user has given.
Is there a way that i can run a single code that matches all the set of days the user has given and run the respective code pieces?
View 3 Replies
Mar 16, 2011
I am reading .css fle which is having following 2 css classes:
[code]....
View 11 Replies
Mar 1, 2010
I have an ASHX handler or an ASPX page (the problem happens in both cases).
The web client sends a request containing If-None-Match and/or If-Modified-Since headers but context.Request.Headers.Get("If-None-Match") or context.Request.Headers.Get("If-Modified-Since") is null in the handler.
The same script works in my local development machine but it doesn't work in the online machine (both are running IIS7 on Win 2008, .NET 3.5)
View 1 Replies
Sep 30, 2010
hav a gridview, it works when old entites are in the collection because all of these are proxies of the real entity.But if i insert a new Entity using context.User.AddObject(user);context.SaveChanges();The databind to the grid crashes with error, "Object does not match target type", because the old object are proxies of the real POCO, while the new object is of Type User
View 1 Replies
Apr 15, 2010
<asp:TextBox runat="server" ID="Accountname" />
<asp:CustomValidator runat="server" ControlToValidate="Accountname" OnServerValidate="Accountname_CheckUnique" meta:resourcekey="ACCOUNTNAME_UNAVAILABLE" />
protected void Accountname_CheckUnique(object source, ServerValidateEventArgs arguments)
[code]...
View 1 Replies
Apr 24, 2010
I am using regular expressions for matching only digits, minimum 10 digits, maximum 14. I tried:
^[0-9]
View 5 Replies
Apr 15, 2010
I have registered the following SEO friendly route:
[Code]....
Anyone an idea how to fix this problem? Returning a 404 is not a nice UX when (in our case) only the id really matters ...
View 7 Replies
Apr 15, 2010
Given the code below, how do I compare a List of objects's values with a test value? I'm building a geolocation application. I'll be passing in longitude and latitude and would like to have the service answer back with the location closest to those values. I started down the path of converting to a string, and formatting the values down to two decimal places, but that seemed a bit too ghetto, and I'm looking for a more elegant solution.
public class Location : IEnumerable
{
public string label { get; set; }
public double lat { get; set; }
public double lon { get; set; }
//Implement IEnumerable
public IEnumerator GetEnumerator()
{
return (IEnumerator)this;
}
}
[HandleError]
public class HomeController : Controller
{
private List<Location> myList = new List<Location>
{
new Location {
label="Atlanta Midtown",
lon=33.657674,
lat=-84.423130},
new Location {
label="Atlanta Airport",
lon=33.794151,
lat=-84.387228},
new Location {
label="Stamford, CT",
lon=41.053758,
lat=-73.530979}, ...
}
public static int Main(String[] args)
{
string inLat = "-80.987654";
double dblInLat = double.Parse(inLat);
// here's where I would like to find the closest location to the inLat
// once I figure out this, I'll implement the Longitude, and I'll be set
}
View 4 Replies
Dec 17, 2010
I'm baffled as to why this error keeps popping up all the time....
i've created handlers in IIS7 to map requests for static content.
I've added the following line to my routes:
routes.IgnoreRoute("rest/schema/{file}.xsd");
I've checked that the file is physicly present on the location, yet MVC keeps bitching about not beeing able to find a route. What is the IgnoreRoute for then if it keeps searching?
View 3 Replies
Nov 20, 2010
I want a regular expression patterns to match for the following example.
USER@DOMAIN.COMDOMAIN\USERUSER
I need only the USER to be extracted from those.
View 2 Replies
Nov 22, 2010
i want to run javscript from code behind if some condition match
In page load i have a sub progrme
Private Sub Runscript()
' Execute javascript some condition match
dim i as integer=0
if i=0 then
'execute javascript alert
end if
End Sub
and javascript is
function Alert() {
alert("Hai");
}
i am calling this some sub programme Runscript in pageload
View 6 Replies
Mar 10, 2010
I need to match the content on web.For example consider I have one sample code,if i submit that code it should search on web and display the website url where that code exists. I need the code in asp.net and c#.
View 1 Replies
Aug 4, 2010
I have a table in the db with one column containing a URL like http://site.com/users/*/profile.I am given a URL (like http://site.com/users/234/profile) and want to select all the rows in the db that match the url (in this case * is a wildcard).
I was thinking of using Regex to do this, by replacing the * with regex for any character. But am unsure as to what the SQL or LINQ code should be for the selection.
View 2 Replies
Aug 22, 2010
Here is the kind of text I want to match via a regular Expression
The id="dgSchedule" is always present in the TAG but its location may differ
The table is span over multiple line/contains white spaces/tabs...
I have the regular expression to match the start and end tag respectively over a single line
[Code]....
Is there any regular expression generator available that can generate me a regular expression based on the text I select and the parameters I specify?
View 6 Replies
Feb 10, 2010
can someone tell me the regex pettern to match a string from [a-zA-Z] where each character in the group cannot occur more than n number of times.
View 8 Replies
Mar 30, 2011
The default validation in MVC 3 is based on jQuery Validation, which I can usually customize with something like:
$.validator.setDefaults({
submitHandler: function() { alert('submitHandler'); },
errorPlacement: function(error, element) {
// do something important here
alert('errorPlacement');
},
errorClass: "error",
errorElement: "input",
onkeyup: false,
onclick: false
})
View 1 Replies
Apr 25, 2010
looking on my servers application logs i noticed a contiuous for days now attempts to login to my sql serverReason: Password did not match that for the login provided.
View 3 Replies
Feb 20, 2010
Formview1 is databound to SQLSource that has a while condition. this while condition has a term which is a control in my page set by user. The problem is when there is no match (between users' value and database) the page *becomes blank*
i want the controls of my formview and rest of the page to still be available
View 1 Replies
Apr 9, 2010
I have a regular expression
^[a-zA-Z+#-.0-9]{1,5}$
which validates that the word contains alpha-numeric characters and few special characters and length should not be more than 5 characters.
How do I make this regular expression to accept a maximum of five words matching the above regular expression.
View 3 Replies
Jan 24, 2011
What i am trying to achieve is that there are 7 columns in my db table. one is primary key and rest 6 are integer columns. Now my application will allow user to input 6 values. I want to compare 6 values entered by user to those 6 integer columns and if in any row 3 or more columns match user's input Primary key of that table is returned..
I have tried using queries, cursor, nested loops and i am still unable to achieve my results..
DB Table Structure.. I am inputting 2,3,7,11,45,65. Number of returned rows should be 5. eg..
UID A1 A2 A3 A4 A5 A6
-----------------------
1 2 3 4 5 6 7
2 2 3 4 55 56 57
3 65 11 45 66 67 68
4 45 7 11 99 98 97
5 7 7 7 7 7 7
6 7 7 7 7 7 7
7 8 8 8 8 8 8
8 8 8 8 8 8 8
9 45 45 0 3 1 2
10 65 7 4 0 0 0
IDs returned should be 1,3,4,9,10
View 6 Replies