473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to scan for flags in a string, removing them, and processing each one.

eragon
431 256MB
I am creating an Ajax/PHP based console-type-thing, where basically the user enters a command at the prompt, it gets sent to a PHP script to get chewed up and processed, and a string of crap comes back out to be displayed.

I would like to know if anyone knows a nifty way in Javascript that I can check if certain flags are present in the return from the server, known as the variable req.responseText.

Some examples:

Expand|Select|Wrap|Line Numbers
  1. // Server Returns:
  2.  <br />{p}Please enter your password:
  3.  
  4. // Java should see the {p} as a flag, and the equivalent should occur:
  5. document.getElementById("input").type='password'; // Line 1
  6. output = "Please enter your password:"; // Line 2
  7.  
  8. // As you see, I need several lines similar to the first to execute 
  9. //   whenever a flag is found, and multiple flags should each work, 
  10. //   such as {c}{p}.
  11. // I would also like to be able to use paramaters, such as:
  12. {m=location_mapped, 90, 100}Server Return Text
  13.  
  14. // So that it would process if the flag was "m" with three parameters equal to location_mapped, 90, and 100.
  15.  
Any help is greatly appreciated.
May 19 '10 #1
1 1234
acoder
16,027 Expert Mod 8TB
You may be better off with XML or JSON.

You can use some of the String methods to grab the flags, e.g. split(), or match() with a regular expression, or even get character by character with charAt().
May 19 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Steve Dorsey | last post by:
Hello I'm creating a web page that contains a flash presentation. I currently have it resizing the user's web page and placing it on the screen using this script: ...
4
by: Kevin | last post by:
I have a routine that is copying chunks of a super large string into a new order. It is acting as a message translator. For certain source messages, the string routines seem to stop, and the cpu...
13
by: Mark A. Odell | last post by:
I write a lot of drivers and there is inevitably some hardware register or buffer descriptor field called 'flags'. The flags are defined, typically, as bit positions. I was thinking I could get...
0
by: RMD | last post by:
I have a portal application that uses UserControls as "portlets" inside the portal. One feature of the portal is the ability to maximize and minimize portlets, just like you would applications in...
2
by: KB | last post by:
Hi guys, In my DataGrid I have a column that displays decimal values as currency ( I set the Data Formatting expression of that column to {0:C}). So the actual string displayed in the grid looks...
2
by: Brian Henry | last post by:
Is there any quick and easy (other then scanning a string char by char) to remove all the alpha chars from a string and leave only numbers? ex: A12334234-3431AP comes out to 123342343431...
16
by: junky_fellow | last post by:
Is there any efficcient way of removing the newline character from the buffer read by fgets() ? Is there any library function that is similar to fgets() but also tells how many bytes it read...
3
by: =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post by:
Hello, I've eliminated the bulk of code, this should be sufficient: byte fromEncrypt; string sDecryptedString; //Read the data out of the crypto stream. csDecrypt.Read(fromEncrypt, 0,...
3
by: DotNetNewbie | last post by:
Hi, I want to parse a string, ONLY allowing alphanumeric characters and also the underscore '_' and dash '-' characters. Anything else in the string should be removed. I think my regex is...
0
by: BillE | last post by:
Using VB.NET, VS 2008 v9.0.21022.8 RTM, Windows Forms project. I have entered several settings of type (connection strings) on the Settings tab in the project properties screen. They all have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.