MY problem is related to entry of research data.

The researchformula is entered into a textbox alongwith other usual form entries like title,subject,startdate etc.

The formula consists of alzebra, trignometric, otherfunctions etc.

Example

[B]x = 12;
y = 24 + tit[x] + mixer[x];
z = x + sin(x) + tan(x+y) - max[x,y];

#final result is 24.778273666352;[/B]

The program is not concerned with the syntax or result of these formulas.

The form must however display some details of the formula in the following format in textbox on buttonclick

a) variableused name and characterlocation of variables like x(1,19) y(8,)
since x is at 1,19 position and y starts at 8 position

b) functioused name,location - same as above


> variablenames and functionname always start with a alphabet
> the only difference is functionname is always followed by a parenthesis( ) ot bracket[ ]
> # symbol denotes a comment and need not be considered
> all statements are separated with a semicolon including #


would greatly appreciate any guidance related to this query.

Maybe you can find some ideas here: http://www.daniweb.com/software-development/csharp/code/217185

the above method does not find positions of a text within another text.

thanx , but i am working on the following methods

a solution with an approach of finding text within a text using regular expression

OR

even a for loop that can first generate a list of present variables and functions

Look for the members of the String class: http://msdn.microsoft.com/en-us/library/system.string_members(v=vs.90).aspx
e.g. the IndexOf method : http://msdn.microsoft.com/en-us/library/system.string.indexof(v=vs.90).aspx

thank you, i think indexOf is the key because it gives the exact position of the text.

Infact, i have asked the question incorrect way. My question was as simple as

How to find occurances of a Text in a Text ? of which i found a very common solution however the problem occur when it matches to a textpart for ex.

x does occur many times in a equation and it Also occurs in function max[1,2,3,]

that is where i am stuck now.

So, perhaps you want more something like this: http://www.dijksterhuis.org/manipulating-strings-in-csharp-finding-all-occurrences-of-a-string-within-another-string/

Thanx again,

This was a good example, I wrote a for loop with indexOf but this class seems hi-tech.

The problem is that it also fails to omit char within a word

for ex.

if a text is x = x + max[y,x];

the char x is show to occur four times in place of 3 i.e. it counts the x within the word max.

I wrote a if statement to omit it, but the combinations of a letter being standalone is high like it may have a space as prefix or postfix , it may also have a symbol like + - etc. as prefix or postfix.

i am working on a solution that uses regex to find if it is within another text. because it covers whitespace,a-z,A-Z,0-9,_,() that is what there is at the most.

this solution is for a research based project that uses advanced mathemathics.

thanx for all the replies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.