ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 3rd, 2003, 12:57 PM
esthera esthera is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 esthera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question reversing text

I want to reverse text. Basically the text is in hebrew and the best way for me to display it is to switch each word within a sentence around doing sentence at a time.

For example asp is fun to program in would be psa si nuf ot margorp.

I'm not sure where to start. Any suggestions in how to do this?

Reply With Quote
  #2  
Old September 3rd, 2003, 02:09 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 8
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
strReverse

the function strReverse reverses a string.

You can program the following:
Split the string into an array with space as delimiter,
For..Next through the array and use strReverse on each array element,
and Join the array with space as delimiter.

Code:
strTest = "asp is fun to program"
aString = Split(strTest, " ")
For i = 0 To Ubound(aString)
   aString(i) = strReverse(aString(i))
Next
strTest = Join(aString, " ")
__________________
- Rogier Doekes

Reply With Quote
  #3  
Old September 4th, 2003, 01:40 AM
esthera esthera is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 esthera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks,
How would i add to do line by line at a time between each <p></p> or <p align=xxx> and</p> not including the paragraph marks

Esther

Reply With Quote
  #4  
Old September 4th, 2003, 04:15 AM
esthera esthera is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 esthera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
actually in addition to above also
I need it to be between ascii 224 and 251 so thatit doesn't reverse english or html.

Can you help me with any of these steps?

Esther

Reply With Quote
  #5  
Old September 6th, 2003, 05:17 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 8
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
Well Esther,

I tried my best to whip up some code. Be sure to test the code, since I loosely tested it, and I am not able to read hebrew on my browser.
Code:
<% Option Explicit
'dump the whole text in a variable
'search in the variable for <p and > and </p> (InStr)
'Split the in between text delimiter space
'Loop through the split array and search for ASC 224 - ASC 251
'If there are characters in that array element, reverse
'Join Array and add to the output variable

Dim strInput 'input string
Dim strOut   'output string
Dim aPar, i, j 'word split and indexes for loops
Dim intCurrentPosition 'where are we in the text
Dim intParTag, intParTagLength 'what position starts the <p> tag and how long
Dim intParCloseBracket  'what position ends the <p> tag
Dim intParEndTag 'what position start the </p> tag
Dim bNeedReversal 'flag to determine whether reversal is needed or not

'your input string
strInput = ""

'initialize output string
strOut = ""

'start at the beginning of the text file
intCurrentPosition = 1

'loop thru the text file
Do While Not intCurrentPosition > Len(strInput)
  'position of the paragaph tag
  intParTag = inStr(intCurrentPosition, strInput, "<p", 1)
  If intParTag > 0 Then  'found a pararagh tag
    'end position of the paragraph tag (<p> is smaller then <p align="left"> ;))
	intParCloseBracket = inStr(intParTag, strInput, ">", 1)
	
	'start position of the end paragraph tag
	IntParEndTag =  inStr(intParCloseBracket, strInput, "</p>", 1)
  Else  'did not found a par tag
	intParEndTag = 0
  End If
  
  If intParTag = 0 Or intParEndTag = 0 Then 'exit routine to grab the remaining document
	strOut = strOut & Mid(strInput, intCurrentPosition + 1, Len(strInput) - (intCurrentPosition -1))    
  	Exit Do
  ElseIf intCurrentPosition = 1 Then 'grab the beginning of the document
    strOut = strOut & Mid(strInput, intCurrentPosition, intParTag - 1)
  End If
  
  'add paragraph tag
  intParTagLength = IntParCloseBracket - (intParTag - 1) 'how long is the tag?
  strOut = strOut & Mid(strInput, intParTag, intParTagLength)

  'split the paragraph text into words
  aPar = Split(Mid(strInput, intParCloseBracket + 1, (intParEndTag - 1) - intParCloseBracket), " ")
  
  'loop thru words
  For i = 0 To Ubound(aPar)
    'do we need to reverse flag
    bNeedReversal = True
    For j = 1 To Len(aPar(i))  'loop thru characters of each word
      If Asc(Mid(aPar(i), j, 1)) < 224 Or Asc(Mid(aPar(i), j, 1)) > 251 Then
         'english characters or HTML characters
	     bNeedReversal = False
	     Exit For
             End If  'asc test
    Next 'j
    
    'reverse word only when reversal flag is set
    If bNeedReversal Then aPar(i) = strReverse(aPar(i))
    
  Next 'i
  
  'paste all the words back together
  strOut = strOut & Join(aPar, " ")
  
  'add end paragrap tag
  strOut = strOut & mid(strInput, intParEndtag, 4)
  
  'move the currentposition up to new paragraph
  intCurrentPosition = intParEndTag + 3
Loop

Response.Write strOut 'display final result
%>

Hope this helps,

Reply With Quote
  #6  
Old September 7th, 2003, 03:06 AM
esthera esthera is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 esthera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
wow thanks!

I'm going to try this out. It looks good!!!
Thanks for the help.

Esther

Reply With Quote
  #7  
Old September 9th, 2003, 01:21 PM
esthera esthera is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 esthera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've been playing with your above code. thanks for the help.
Would you know how to switch the direction of the sentence to right to left also. (Also only if it's within the ascii code that I specified)

Thanks,
Esther

Reply With Quote
  #8  
Old September 20th, 2003, 10:58 AM
Enigma Enigma is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Manchester, England
Posts: 1 Enigma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The default text direction setting is "ltr" (left to right), you will need it to be "rtl" (right to left) for the hebrew text.

If the hebrew text takes up whole paragraphs seperate from any english text, you could use <p dir="rtl">. If it applies to a whole table cell then <td dir="rtl"> or an entire table then <table dir="rtl">.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > reversing text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek