0

This is my vbscript to read the text file .. I want to know how to split some of the chinese characters.
In my code it prompts the Text Line by Line with chinese characters my problem is how to split the chinese characters and the open and close pharenthesis
thank you

Example
Original:
45029 * 小(xiao3) 姐(jie3) * 郑(zheng4)
45023 * 平(ping2) * 何(he2,he4)
45024 * 文(wen2) 鑫(xin1) * 阎(yan2)
45025 * 艳(yan4) * 崔(cui1)
45026 * 唐(tang2) * 建(jian4) 平(ping2)

The output I need:
45029 * Xiao * Zheng
45023 * ping2 * he he

========================

Option Explicit
'Read Text Line By Line

Dim objFSO, strTextFile, strData, strLine, arrLines
CONST ForReading = 1

'name of the text file
strTextFile = "CName.log"

'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Open the text file - strData now contains the whole file
strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAll

'Split the text file into lines
arrLines = Split(strData,vbCrLf)


'Step through the lines
For Each strLine in arrLines
wscript.echo strLine
Next

'Cleanup
Set objFSO = Nothing

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by lolafuertes
0

I would suggest do some thing like:

Option a:

1) Define the characters to be separators_cahrs
2) Define the valid_result_line
3) Define a boolean to be true is the_previous_charactes_was_a_separator
4) For each character in the strLine
a) if the_previous_charactes_was_a_separator and this character is a separator_char
* Continue the foreach
b) if this character is a separator
* add a predefined separator in the valid result line
* set the_previous_charactes_was_a_separator to be true
* Continue the foreach
c) add the current char to the valid_result_line and set the_previous_charactes_was_a_separator to false
5) Split the line using the predefined separator char.

Option b:

1) Define the characters not_to_be_separators
2) Define the valid_result_line
3) Define a boolean to be true is the_previous_charactes_was_a_separator
4) For each character in the strLine
a) if the_previous_charactes_was_a_separator and this character is a separator char
* Continue the foreach
b) if this character is a separator
* add a predefined separator in the valid result line
* set the_previous_charactes_was_a_separator to be true
* Continue the foreach
c) add the current char to the valid_result_line and set the_previous_charactes_was_a_separator to false
5) Split the line using the predefined separator char.

To determine if the curent char is a separator you can create a function to return if this is a separator char or not depending on the option a or b.

Hope this helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.