|
First of all, why are you matching the above characters instead of just using the \w (word characters) and \s (whitespace characters) character classes? It appears you are trying to do something like the following (with slightly more control)
myString = myString.Trim(); Second, if you really want to remove things in the middle, instead of a regex do the following:
myString = myString.Replace("\t", string.Empty);
myString = myString.Replace("\b", string.Empty);
-Jeff
|
|
|
|
|
I have a method which uses regex.... shown below
<b>string pattern = "(?<before>.*)(?<junk><table class="MyTable" cellspacing="2" cellpadding="1" width="144" border="0">.*</table><!--MyTable- -->)(?<after>.*)";
string matchEvaluator = "${before} ${after}";
try
{
local_string = Regex.Replace(local_source, pattern, matchEvaluator);
}
catch (Exception er)
{
string g = er.Message;
}
string wr = HTMLWriter.htmlWriter.WriteHTMLFile(@"C:\trimExtras.html",
local_string);</after></junk></before></b>
I want to remove certain part of html page with this regex
the problem is it does not work... it takes a long time i.e hangs the app and when i write it to html file its still the same i.e does not replace any thing
<div class="ForumMod">modified on Friday, December 07, 2007 7:52:14 AM</div>
|
|
|
|
|
Question: A curiosity, doubt, or statement inquiring about something.
Did you forget something?
|
|
|
|
|
string test0002 = "Select room_code from room_types where room_code = '" + room_code + "'";
int max2;
SqlCommand cmd17 = new SqlCommand();
cmd17.Connection = con2;
cmd17.CommandText = test0002;
max2 = (int)cmd17.ExecuteNonQuery();
lbtest1.Text = max2.ToString();
hey is there a problem with the code above as its not displaying the data it is meant to, is there another way t display data from a query quickly/
cheers
|
|
|
|
|
did u get any error while running this code?
|
|
|
|
|
The return value from ExecuteNonQuery is the number of rows affected. In the case of a Select statement this will usually be zero.
You shold use ExecuteScalar to get a single return value from your select statement, or ExecuteReader to get more than one return value.
|
|
|
|
|
Please consider renaming your command to something more meaningful than cmd17, and don't use inline SQL like this - it's wide open to SQL Injection attacks. This[^] article should help.
|
|
|
|
|
-------------------Program.cs--------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication1
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.SetCompatibleTextRenderingDefault(false);
Form1 obj = new Form1();
TimerCallback tcallback = new TimerCallback(obj.Child);
ThreadPool.QueueUserWorkItem(new WaitCallback(tcallback));
long dTime = 1000 ;
long pTime = 10000 ;
System.Threading.Timer atimer = new System.Threading.Timer(tcallback, null, dTime, pTime) ;
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
}
-------------------------------------------------------------------------
----------------------------------------Form1.cs-------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void Child(object state)
{
//textBox1.Text is the problem. This value is not shown on form.
textBox1.Text = "Some Text";
MessageBox.Show(textBox1.Text);
}
}
}
-------------------------------------------------
|
|
|
|
|
Hi..
Nice Subject
you can not change the text of a control from another thread.
try the following:
public void Child(object state)
{
if (textBox1.InvokeRequired)
{
Invoke(new TimerCallback(Child),new object[]{state});
}
else
{
textBox1.Text = "Some Text";
MessageBox.Show(textBox1.Text);
}
}
alternatively you could also use System.Windows.Forms.Timer instead of the one in the Threading - Namespace. then you wouldn't have to use Invoke.
hope this helps
m@u
|
|
|
|
|
Hi
I ahve the following problem
I ahve a field in a database with field format jh00~pr11_ 01
howecer when a person adds a new row i need the last number to autoincrment so the next one would be: jh00~pr11_ 01
however the problem is i cant do this in the database end i need to do it in c#
any starters or suggestions?
cheers
|
|
|
|
|
Jamie1985 wrote: I ahve a field in a database with field format jh00~pr11_ 01
howecer when a person adds a new row i need the last number to autoincrment so the next one would be: jh00~pr11_ 01
Boot the string looking same !!!
I belive it will be incremented in jh00~pr11_02,jh00~pr11_03 this way ???
if this !! use Substring() and indexof() for that !!!
you can find position of _ using indexof
hope this will help !!!
|
|
|
|
|
Yeah, you could probably use .Split on the underscore:
string db = "jh00~pr11_01";
string[] split = db.Split('_');
string s_number = split[1];
int i_number = Int32.Parse(s_number);
i_number++;
s_number = i_number.ToSrting();
db = split[0] + "_" + s_number;
There's probably stuff wrong with that code, but you get the idea.
Separate the number from the rest of the string, increment it, and add it back on.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
thats great thanks
how would i make it 02 on the end instead of just 2 as its doing at the mo?
cheers!!
|
|
|
|
|
of course, use .PadLeft(2, '0'); which will add 0's to the start until the length of the string is 2
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
On invoking the form that contains the Datagrid view the DataGridView Default Error Dialog appears...
I am unable to handle this event. Can anyone tell how to prevent this dialog from appearing.
|
|
|
|
|
I am pretty sure there has to be a method after that.
but i dont no if that is write.
ollie
|
|
|
|
|
Thank you ollie for your reply...
I have resolved the problem...
Using the DataGridView.DataError event and catching the exact error worked out...
modified on Friday, December 07, 2007 7:46:56 AM
|
|
|
|
|
|
Hi,
Is is possible to read all class name from a assembly.
USing reflection i can read class name and all other inforamtion of it. but i want to get the class name from some other Csproj file so i need to read the assembly of that file !!!!
Any idea !!!!
Thanks in advance !!!!
|
|
|
|
|
Abhijit Jana wrote: Is is possible to read all class name from a assembly.
Yes. From the Assembly object you can use the GetTypes() method which returns an array of Type objects.
Abhijit Jana wrote: but i want to get the class name from some other Csproj file so i need to read the assembly of that file !!!!
Yes, you can use one of the static Load methods on Assembly. If you only want to query the assembly without running code on it you can use one of the ReflectionOnlyLoad methods instead.
|
|
|
|
|
|
(for example)
Type _type = Assembly.GetAssembly(this.GetType()).GetType("class name");
or
Type[] array = Assembly.GetAssembly(this.GetType()).GetTypes();
|
|
|
|
|
Hi,
I am building a windows application that can show list of files from a folder that is placed in web site. I mean to say on web server. Let us suppose there is a folder on localhost named as Test. Now i want to display all files' mame in a list view. Is there anybody has any helping material that can help me as well. Thanks in advance
|
|
|
|
|
|
I've tried this one but this is only for local system. But i want to fetch the files from a folder placed on Web Server to a local system. I can read files as stream but how can i get the list of file from a folder placed in a web site.
|
|
|
|