Visual C++ :: Regular Expressions - How To Get Iterator

May 22, 2014

In order to parse mathematical expressions I am trying regular expressions and a recursive algorithm, but I have a problem with the four basic operations: +, -, *, /.

Trying to analyze a string like "a+(b+c)", if I use the pattern for a sum "(.+)+(.+)" the program matches it recognizing as subpatterns: "a+(b" and "c". How could I achieve the program to try also the other possibility?

I think that it would be great something like an regex_iterator which worked with regex_match instead of regex_search. I mean, an iterator that iterates over all the possible ways to match a given regular expression and a given string. This way I could loop through all these possibilities until the two subpatterns produced were correct mathematical expressions.

View 3 Replies


ADVERTISEMENT

C++ :: Regular Expressions Not Working?

Aug 25, 2014

I have this bit of code that I found here: [URL] and at first regex would work, but then when I hit "[]" it wouldn't. Here's the code:

#include <iostream>
#include <string>
#include <regex>

[Code]....

View 2 Replies View Related

C++ :: Use Boost / Regex For Regular Expressions?

Sep 5, 2013

So I need to use boost/regex for regular expressions. someone told me that it needs to be built. the first problem is boost doesn't tell you how to build it and the second is i did sudo apt-get install libboost something. I don't remember the exact name of the package. it installed but i dont know how i would build it when its installed.

View 2 Replies View Related

C++ :: Email Validation Without Using Regular Expressions?

Dec 11, 2013

writing a program for "Validating the e-mail id without using regular expressions in c/c++"?

View 4 Replies View Related

Visual C++ :: Error Assigning Pointer To Iterator

Nov 27, 2014

im trying to port a code from vc6 to vs2013 and im having this error

Code:

Error11error C2440: 'initializing' : cannot convert from 'char *' to 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<char>>>' on this line

Code:
vector<char>::iterator BufIt = (char*)lpBuffer;

what i do with this is to stack fragments of data of type char* coming from a socket in buffer to a vector that acts as buffer, I do this since I transfer big chunks of data and the data gets fragmented by the nature of the sockets, I stack the data once its complete I retrieve the final result from the vector.

this code worked flawlessly for long time but now Im trying to port and compiler throws this error, whats the new way to assign a char array pointer to a iterator so i can stack it in the vector.

View 5 Replies View Related

Visual C++ :: Program To Print List Using Iterator And Operator Overloading

Nov 19, 2014

I'm trying to use the given Iterators to overload my = operator to print my list to screen. I keep getting Link2019 error though and have narrowed the problem down to my print operator. I'm wondering if it has anything to do with the fact that my operator is in private part of class? I'm new to this concept.

Code:
#include "List.h"
// methods for Node all
//ME
Node::Node( const string &s, Node * p, Node * z) : word( s ), next( p ), prev(z)//constructor {
word = s; // init. word data with a copy of s
next = p; // next pointer points to p

[Code] .....

View 1 Replies View Related

C :: Building NFA From Regular Expression

Oct 23, 2013

I am trying to create a NFA from a regular expression. I have a grasp on reading in the regular expression and being able to make a stack from it. The part I am struggling on is mapping the characters in the regular expression to an integer indicating the variables order in the expression. I am just not sure how to go about this.

My code so far...
Code:
#include<stdio.h>
#include<stdlib.h>
#include "stack.h"
int main(void)
{
char expression[80];//array to store regular expression

[Code] .....

View 6 Replies View Related

C :: Cannot Use Array Name In Expressions

Nov 27, 2014

Code:

int main() {
char *arr[] = {"Hello", "World", "Good", "Morning"};
display(arr);
return;
}

[code]....

The code works fine and prints the 4 strings. Where i m riddled is whether "ptr" in display function is a pointer or a string ? If it's a pointer then what is the type of the pointer? If it's an array, then as per my understanding, we cannot use an array name in expressions such as ptr++ (K&R).

View 2 Replies View Related

C++ :: Calculate A Person Regular Pay As Well As Overtime

Jun 26, 2013

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main () {

[Code] ....

I'm not sure why my loop isn't running right. I've also used if/if and if/else . Nothing worked

View 2 Replies View Related

C++ :: Declaring Pointers Vs Regular Variables?

Aug 9, 2013

I really do not see the difference between these two declarations:

int myvariable;
int * mypointer;

It is said that when you define a pointer, instead of containing actual data, it contains a pointer to the memory location where information can be found.

But doesn't the other variable declaration do the same? It obviously doesn't have data either. And it must be stored in a memory location as well. So I do not see the difference.

View 6 Replies View Related

C# :: Cannot Convert Lambda Expressions

Mar 31, 2015

I get the following error:

Cannot convert lambda expression to type system delegate because it's not a delegate type (on invoke).

The Second error is: Client.PrivateChat.txtReceive is inaccessible due to its protection level..

private PrivateChat pChat;
private void client_Received(Client sender, byte[] data) {
this.Invoke(() =>
{
for (int i = 0; i < clientList.Items.Count; i++) {
var client = clientList.Items[i].Tag as Client;
if (client == null || client.Ip != sender.Ip) continue;

[Code] .....

View 4 Replies View Related

C :: Printing Current TIME At Regular Intervals

Aug 22, 2013

Its a code in module of my program, where I need to print current time (HH:MM:SS) at regular intervals.

Code:
#include<time.h>
#include<stdio.h>
//#include<windows.h>
void delay(unsigned int t){ // loop for some delay.

[Code] ....

But when I am running this code I expect this to print difference in time due to delay. But it doesn't enter the delay loop, why ?

View 5 Replies View Related

C Sharp :: Regular Expression To Find A Value In String

Apr 9, 2012

<IMG border=0 alt="UserDeviceId = 70813215">

Above is the sample string object from this i need to find the integer value of UserDeviceId.

View 2 Replies View Related

C++ :: Evaluating Logical Boolean Expressions

Jan 10, 2013

I am looking for a library to aid me in evaluating Boolean expressions. For example, i have an expression like this:

(1*(5+3)+9*65/5-(354*4565*5643+98) >= 12345) && ( 654*987+123 || (2345 > 23423 && 1 != 2)))

(It can also be much longer!) and would like to evaluate them to a true/false boolean.

There are tons of libraries to calculate the (numerical) result of a mathematical expression, but this is not what i want to do.

View 5 Replies View Related

C++ :: Program For Billing System - Regular Package Function

Jan 5, 2015

I have programmed a program for billing system. I have used parameters and arrays. All the functions are working except a one function. (Regular package function).

#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
void main(int &minutes, int &minutesd,int &minutesn) {

[Code] .....

View 3 Replies View Related

C :: Shunting-yard Algorithm To Evaluate Expressions?

Sep 16, 2014

Can I use Shunting-yard algorithm to evaluate Expressions (arithmetic, relational, and logical) ?

View 8 Replies View Related

C++ :: Implement Program For Evaluating Infix Expressions

Dec 3, 2014

Also, can't use namespace std for this.

#include<iostream>
#include<stack>
#include<fstream>
#include<iomanip>
#include<queue>
#include<cassert>

[Code] ....

/* It will read in a infix expression from a text file.check if the parentheses in the input expression are balanced.convert the infix expression into a postfix expression and evaluate the expression.*/

int main() {
string expression;
string postfixExpression;
double result;
testBalanced();

[Code] ....

View 8 Replies View Related

C++ :: Mixed Expressions / Loops And Formatted Output

Feb 22, 2015

1) ask the user to input a mathematical expression in the following format:

NUMBER Operator NUMBER Operator NUMBER
Example: 17 + 15 - 3
Example: 2 * 3 - 4

How to output the answer of the users equation. Is there a function that includes all math operators (+,-,/,*)? Would i need to write each possible scenario using if statements?

View 2 Replies View Related

C# :: Join Tables In LINQ With Lambda Expressions

Dec 5, 2014

i have stuck in a join and i cant figure out where the problem is, i have those tables

public class Themes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }

[Code].....

View 12 Replies View Related

C++ :: Overloading Addition And Comparing Expressions In A While Loop

Apr 28, 2015

I have two questions that are related to each other. The first one is about overloading the addition operator.

I have defined a struct as the following:

Code:
#include <iostream>
#include <string>
struct Sales_data {

[Code] ....

I then overloaded the I/O operators so I could print to the screen information related Sales_data.

Code:
// overload ostream in order for cout to work
std::ostream& operator << (std::ostream & out,
const Sales_data & cSales_data) {
out << cSales_data.bookNo << ", " << cSales_data.units_sold << ", "

[Code] ....

My first issue is with overloading the addition operator. Everyone works correctly except for std::cout << item << std:endl; will no not output the ISBN number only the units_sold and revenue when added together.

Code:
// addition operator rules
Sales_data Sales_data::operator + (const Sales_data & data2) {
units_sold += data2.units_sold;
revenue += data2.revenue;
return *this;
}

Now here is the code in its entirety

Code:
#include <iostream>
#include <string>
// Sales_data structure
struct Sales_data {
std:: string bookNo;
unsigned units_sold = 0;

[code] .....

After total = total + item;, I would like to print the total for this particular ISBN. However, I only get: blank, total units, total revenue where blank is where the ISBN would go but doesn't print after addition. My second question has to do with comparing the ISBN's of the books entered during the while loop. I would like to do something like

Code:
if (item_i.bookNo == item_i+1.bookNo) {
total = total + item;
} else {
std::cerr << "Books entered must have the same ISBNs" << std::endl;
}

Unfortunately, I cannot figure out how to set up a comparison of the bookNos. If I used #include <casset> in the overload + rule, it will immediately exit since I have no way to compare the ISBNs.

View 3 Replies View Related

C++ :: Evaluating Arithmetic Expressions Using Recursive Descent Parser?

Feb 25, 2013

I have the following code to calculate arithmetic expressions :

#include <iostream>
using namespace std;
using namespace std;
const char * expressionToParse = "6.5-2.5*10/5+2*5";
char peek(){
return *expressionToParse;

[code]....

The problem is that it does not work properly with decimal numbers for example it evaluates 6-2*10/5+2*5 = 12 which is correct but for 6.5-2.5*10/5+2*5 it returns 6 instead of 11.5 .

View 3 Replies View Related

C Sharp :: Regular Expression To Read Multiple Groups Of Text From TXT File

Mar 14, 2014

I have an EDI file whose structure is given below. This file has multiple records, each record contains a header (e.g EDI.DD.0000000001.20130809), then contents (i.e multiple paragraphs of text) and then footer (e.g End of Report/No EDI Activity). I have to read that entire file using regular expression using three groups.

I am using following regular expression to read the file.

(?<header>[A-Z]{3}.[A-Z]{2}.[0-9]{10}.[0-9]{8}) | (?<footer> (EndsofsReport|NosEDIsActivity)) |

(?<content>(?<=k<header>).*(?=k<footer>))

That expression reads the "header" and "footer" in respective groups properly but didn't pick the contents between header and footer in "contents" group.

I have changed the font of header and footer in below file to understand the format. I am using asp.net 3.5 framework.

//------------------Start of EDI File---------------------//
EDI.DD.0000000001.20130809

ORIGINATOR INFORMATION Company Name: UNITED HEALTHCAR Identification: 9024125001 Originating DFI: 002100002

RECEIVER INFORMATION Receiver Name: HEALTH & WELLNESS DFI Account Number: 0000000000000001 Receiving DFI ID: 434343430 ID Number: Transaction Type: 22 Deposit

ORIGINATOR INFORMATION Company Nam

[Code] ....

View 1 Replies View Related

C++ :: How To Get Iterator To The I'th Element

Jun 17, 2013

I'm making my first steps in STL, and I have a few question:

Is there a way to get an iterator to the i'th element in the collection (set or list), instead of just to the end or the begin?

And another question: Let's say I have an iterator, pointing to some element in my collection, and I use erase() (which takes as parameter an iterator that points to the soon-to-be erased element), what happens to that iterator? will it now point to NULL?

View 7 Replies View Related

C/C++ :: How To Declare Iterator

Aug 20, 2014

I have this class with template:

template<template<class, class> class ContainerType>
class Movie {
public:
typedef ContainerType<Actor*, std::allocator<Actor*> > Container;

and i have a member func to find actor in movie according to actor id:

const Actor* findActor(int id) const {
typename Container::iterator it;
Actor* p(NULL);
it=actors.begin();
std::for_each(it,actors.end(),(*it)->getId()==id?p=*it:0);
if (p==*actors.end()) return NULL;
return p;
}

I receive error that no match for operator= in it.

How to declare correct iterator ?the type of actors is Container..

View 6 Replies View Related

C++ :: How To Declare Class As Forward In Header File - Regular Use In CPP File

Jan 17, 2015

lets say we have a valid class with full implementation, X. can this class be declared as forward in Y header file:

Code: class X;

class Y{
X* m_X;
}

but still be used as regular in the cpp file?

Code:

#include "Y.h"
#incldue "X.h"
T Y::function(){
m_X->doSomething();
}

visual studio prevents me from doing it , I wonder if the standard also says so.

View 2 Replies View Related

C++ :: Cannot Dereference Iterator At The End Of List?

Apr 8, 2014

Why this code works
Elenco e1;
e1.add(Persona("a","b"));
e1.add(Persona("c","d"));
e1.add(Persona("e","f"));
e1.add(Persona("e","f"));
e1.remove(2); //list of 4 elements

but this not work?
Elenco e1;
e1.add(Persona("a","b"));
e1.add(Persona("c","d"));
e1.add(Persona("e","f"));
e1.remove(2); //list of 3 elements

This is remove method:
Persona Elenco:: remove(int pos){
list<Persona> ::iterator iter=l.begin();
for(int i=0 ;i<pos;i++){
iter++;
}
return *(l.erase(iter)); //erase ritorna un iterator
}

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved